LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem on regular expression

Solved!
Go to solution

Hello everyone,

 

I am working on a project that require me to seperate the following examples:

 

+0,+0.0000+E1,-4.33+E1,-4.222+E1,-6.33+E2,-6.55+E2

 

What I need is the final four results seperately:

 

-4.33+E1,

-4.222+E1,

-6.33_E2,

-6.55+E2.

 

I am totally fresh to regular expression. Any help is well appreciated!

 

 

Thanks,

 

+Kunsheng

 

0 Kudos
Message 1 of 12
(3,892 Views)

Take a look at the code below.  It doesn't make much use of RegEx, but I think it is simpler.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 03-05-2009 12:42 PM
Message Edited by jmcbee on 03-05-2009 12:43 PM
Download All
Message 2 of 12
(3,881 Views)

Try feeding the string to the Spreadsheet String to Array function with comma (,) as the delimiter and string as the datatype.  This should give you an array of strings with each of the values in a different element.  Then use an expanded Index Array node to get your last four results.  If you need the commas at the end of these strings, you may need to concatenate them back on as the first step above will remove the delimiters.

 

No regular expressions required. 

 

Lynn 

Message 3 of 12
(3,880 Views)
I think we need more definition here.  Do you want to keep all non-zero values or do you want to keep the last four values in the set?
Message Edited by jmcbee on 03-05-2009 12:48 PM
0 Kudos
Message 4 of 12
(3,873 Views)

What are the rules? I don't see any simple pattern in your example.

  1. drop first two values, retaining the last four.
  2. replace comma with "comma+linefeed"
  3. replace the second-to-last "+" with an underscore (-6.33+E2  ---> -6.33_E2) Why???
  4. Do you really want the comma at the end of each line in the output?

Maybe something like this gets you partway there:

Message Edited by altenbach on 03-05-2009 01:04 PM
Message 5 of 12
(3,853 Views)
Solution
Accepted by topic author Kunsheng Chen

Hi, Kunsheng

 

Good evening exercise for learning regular expressions...

 

For example, quick and dirty:

 

 

I have strong feeling that something wrong here (I guess in ([0-9]+[1-9]+)), but anyway the code above is just starting point for you.

 

Andrey.

Message Edited by Andrey Dmitriev on 03-05-2009 10:18 PM
Message 6 of 12
(3,845 Views)

Upd:

 

Or more easy version if strings with zeroes allowed:

 

Message Edited by Andrey Dmitriev on 03-05-2009 10:30 PM
0 Kudos
Message 7 of 12
(3,835 Views)

Awesome! thanks for all of you! I am sorry I didn't mention that clearly enought, but the last one is definitely the solution I need!!

 

Thanks a lot!

 

Best,

 

+Kunsheng

0 Kudos
Message 8 of 12
(3,830 Views)

Welcome!

 

But be careful with numbers like this: +0,+0.0000+E1,-4.0330+E1,-4.222+E1,-6.33+E2,-6.55+E2

The code above will skip this number. So, I would recommend to use second solution, and then delete "zero numbers" from array, outside of regular expression.

 

Andrey.

0 Kudos
Message 9 of 12
(3,824 Views)
Is 0+E1 a legitimate scientific notation number?  Generally zero would be 0+E0. 
0 Kudos
Message 10 of 12
(3,806 Views)