LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching ^ symbol using regular expression

Solved!
Go to solution

I have a text file as an input string containing 2 columns of date and equation separated by a tab.

Now I want to read that file and search for a specific equation like x^10+5 and replace it with something, so my search string looks like this:

19-07-2021\t3x^10+5\n

this works fine if I search it without using regular expressions but this will only work for a specific date and I want to make it any general date, so I tried:

[0-9]+-[0-9]+[0-9]+\t3x^10+5\n

but this is not giving the result(in fact it is not giving me any result) that I want because of the "^" symbol.

So please help me in searching 3x^10+5 using regular expression.

I hope that I was able to explain my problem properly. Please let me know if something is still not clear. 

Thanks in advance

Best regards

Ankit Yadav

0 Kudos
Message 1 of 8
(2,156 Views)

Escape it with a \.

 

Special characters (., [, (, *, +, $, ^, ], ), \, {, }, |, perhaps others) (often) needs escaping.

0 Kudos
Message 2 of 8
(2,142 Views)

According to manuals found in the internet I'd try

\xhh

where hh is replaced by the hexcode for the circumflex sign.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 3 of 8
(2,136 Views)

Note that the help mentions that LabVIEW uses the PCRE library.

 

So, most online information on that library can be used for LabVIEW regular expressions

 

But some dialects aside, googling "regular expression ...", for example "regular expression capturing groups", will very often give usable results.

0 Kudos
Message 4 of 8
(2,131 Views)

@JensG69 wrote:

According to manuals found in the internet I'd try

\xhh

where hh is replaced by the hexcode for the circumflex sign.

 

Regards, Jens


Simply \^ should work.

0 Kudos
Message 5 of 8
(2,129 Views)
Solution
Accepted by topic author yadavankit9999

You need to use '\' before any special characters.  So you need to add it before the '^' and the '+'.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(2,120 Views)

Thanks, everyone for your quick responses.

I tried this:

yadavankit9999_0-1626695946352.png

 

and as you can see, \^ didn't work without using \+ as crossrulz mentioned. Thanks for it crossrulz.

Thanks, Jens for letting me know something like \x5E, it worked(somewhat) and replaced the ^ symbol only. Like:

yadavankit9999_1-1626696349838.png

 

yadavankit9999_2-1626696412371.png

as you can see it didn't work if I search for \x5E+5( I don't know what I should input in the search string to replace the whole equation😞). 

Best regards,

Ankit Yadav

 

0 Kudos
Message 7 of 8
(2,113 Views)
Solution
Accepted by topic author yadavankit9999

@yadavankit9999 wrote:

Thanks, everyone for your quick responses.

I tried this:

yadavankit9999_0-1626695946352.png

 

and as you can see, \^ didn't work without using \+ as crossrulz mentioned. Thanks for it crossrulz.

Thanks, Jens for letting me know something like \x5E, it worked(somewhat) and replaced the ^ symbol only. Like:

yadavankit9999_1-1626696349838.png

 

yadavankit9999_2-1626696412371.png

as you can see it didn't work if I search for \x5E+5( I don't know what I should input in the search string to replace the whole equation😞). 

Best regards,

Ankit Yadav

 


You need to escape all special characters (as mentioned in the 1st reply).

 

So you also need to escape the +. "E+" matches one or more "E". "E\+" matches "E+".

 

To add to the mix, you can also use \136, where 136 is the octal value for ^.

 

Your expression "\x5E5+5" matches "^55", "^555", and so on.

 

Use "\x5E5\+5" 

0 Kudos
Message 8 of 8
(2,099 Views)