LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match regular expression Escape

Solved!
Go to solution

Hi, I am trying to sort out ESC characters from a file when reading it. This is a constant read of a serial port that has some alignment characters in the form of the ECS button. I can't get the matching expression to work,

As an example this is part of the string :

13;25H 0.0 / 0.0, 0.0 87 0.0 / 0.0, 3.0 87 Rev: 2000.01 Update: 217 87 0.00, 0.00,87 0.650/0.650 87 0.00,0.37,0.02 /87 03ff 87 07ff 87 0256 87 0080 87 30 87 0.0 / 0.0, 0.0 87 0.0 / 0.0, 3.0 87 Rev: 2000.01 Update: 20 87 0.00, 0.00,87 0.650/0.650 87 0.00,0.37,0.02 / 0.43,0.43,0.43 87 0.00,0.00,0.00 / 1.15,1.15,1.15 

 

Regards,

Hans

0 Kudos
Message 1 of 13
(3,723 Views)

If I remove the serial communications and just parse the sample text with your code, this is what I get:

Kyle97330_0-1628639405954.png

Is this not what you wanted?  

 

If you didn't want the Esc character plus the following character to be the "whole match", then what did you want?  If it's just the escape character, you can remove the "." in the search string. 

 

Or did you want more?  I see that there's a repeated string that looks like "87", with the last two numbers changing, is that whole thing what you want?  If so, then you need a much different search string, since "." is just a wildcard for any one single character, and you'll need to add more to get the whole thing.  This one seems to get it all:

\[0-9\;\[H]+

 

0 Kudos
Message 2 of 13
(3,710 Views)

Hi Kyle,

now I got the following response

"LabVIEW: One of the string parameters contains a null character. LabVIEW does not support null characters for regular expression matching."

 

What I want is something tat looks like the screen shot from Putty:(attached).

The code that outputs the numbers on the serial port is adjusting the cursor position vertically and horizontally when the ESC character appears.

 

 

0 Kudos
Message 3 of 13
(3,698 Views)

Hi Hasse,

 


@hasse wrote:

What I want is something tat looks like the screen shot from Putty:(attached).

The code that outputs the numbers on the serial port is adjusting the cursor position vertically and horizontally when the ESC character appears.


These are not just ESC chars, but complete ESC sequences (like described here)!

Those string contains formatting codes for terminals (or terminal emulators) and you need to parse them correctly when you want to achieve the very same appearance of your text!

 

I guess something like "<ESC>[14;25H" describes the cursor position on your (virtual) terminal screen…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 13
(3,678 Views)

Hi Gerd,

I am curious why it is working when I use Putty if it needs special parsing?

 

Hasse

0 Kudos
Message 5 of 13
(3,648 Views)

@hasse wrote:

Hi Gerd,

I am curious why it is working when I use Putty if it needs special parsing?

 

Hasse


It works with PuTTY because it is a terminal program and is processing the terminal escape sequences.  The escape sequences do things like control where the cursor is on your screen in a terminal and whether text and/or the cursor are blinking (and with later terminals, the color of the text).  You have to parse those sequences and do something similar.  Read up on terminal emulation.

 

It's conceptually similar to hypertext, I suppose.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 13
(3,642 Views)

@hasse wrote:

Hi Gerd,

I am curious why it is working when I use Putty if it needs special parsing?

 

Hasse


Think of it this way. The escape characters and sequence are conceptually similar to the following string of data:

 

Hello! [Move cursor to next line command] World! [Move cursor to next line command] My name is Bert! [Move cursor to next line command] [Move cursor to center of screen] The quick brown fox jumped over the lazy dog.

 

A terminal program would see this and display it as:

 

Hello!
World!
My name is Bert!


The quick brown fox jumped over the lazy dog.

 

LabVIEW would read this same command and would simply display the entire raw data stream to you. The terminal program reads the raw command stream data, then actually interprets it for you. This is because the terminal is expected to deal with people who need to see things displayed in certain ways. LabVIEW is more general-purpose than that. If you want to emulate a terminal, you can do so, but the native "Read serial" will just give you the raw data stream. How you interpret it is up to you. Perhaps you are writing a sniffer program, and you'd prefer to view the data in a raw format, like this:

H

e

l

l

o

!

[New line]

W

o

r

l

d

!

[New line]

(etc)

 

Well, you can do that too. LV returns the raw data stream, and leaves the interpreting and display up to the programmer.

 

Message 7 of 13
(3,630 Views)

Hi, I am still struggling with this.

I am not sure if I shall use the Match regular expression or just use a read and parse it. I tried to find the Internet addon 2012, there shall be a Terminal function there but I could not find that anywhere. I don't know if I shall use Telnet, xterm or VT100+ . It is so confusing.

There must be some examples out there? 

0 Kudos
Message 8 of 13
(3,584 Views)

Here's a list of VT100 Commands.  Maybe you could build your own?  (If you do, you might want to make it its own library so you can use it elsewhere.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 13
(3,562 Views)
Solution
Accepted by hasse

@hasse wrote:

Hi, I am still struggling with this.

I am not sure if I shall use the Match regular expression or just use a read and parse it. I tried to find the Internet addon 2012, there shall be a Terminal function there but I could not find that anywhere. I don't know if I shall use Telnet, xterm or VT100+ . It is so confusing.

There must be some examples out there? 


it looks like, you are not meant to use it anymore

 

when I use "search and replace string" (with right click: ✓ regular expressions) instead of "match regular expression", I can turn your example into this:

 

alexderjuengere_0-1629122462322.png

 

search-replace-all.png

 

notice the escape character \ before the [

furthermore, when adding [0-9]+;[0-8]+H you get rid off the none constant string parts at the "beginning"

optionally: add a second stage by applying the same function again with a different search string (regular expressions must'n be turn on here) to get rid off the "end"

 

 

 

Message 10 of 13
(3,511 Views)