LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does '?' in regular expression works?

Hi,

 

I found regular expression as follows ione of teh VI.

 

Regular expression as: [-]?[.]?[0-9]+[.]?[0-9]*

 

The output is, it will extact the number from sentance.

 

Can any oneexplain me with an example (using multiple '?') please how does '?' works?

 

Many Thanks

Haneef

0 Kudos
Message 1 of 2
(2,178 Views)

 


@Haneef wrote:

Hi,

 

I found regular expression as follows ione of teh VI.

 

Regular expression as: [-]?[.]?[0-9]+[.]?[0-9]*

 

 


 

From the help:

?          Marks part of a pattern as one that can appear zero or one time in the input. For example, be? matches be in believe, be in bee, be in beep, and b in bat..

 

So your RegEx consist of the following parts:

[-]?    0 or 1 times the '-' sign

[.]?    0 or 1 times the '.' sign

[0-9]+ 1 or more numbers (0-9)

[.]?    0 or 1 times the '.' sign

[0-9]* 0 or more numbers (0-9)

 

Note that this regex doesn't deal with 'european' decimals using a ',' as decimal character.

 

Ton

 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 2
(2,168 Views)