LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match string pattern

Solved!
Go to solution

I'm looking for a solution to extract a date from a string. The form of the string is uncertain, but the date is always dd/mm/yy and it is not in the beginning or end of the string. I know the Scan From String should be the way to go, but whatever way I try, it will give me an error.

 

Could someone give me some help, thanks in advance.

0 Kudos
Message 1 of 11
(5,192 Views)
Solution
Accepted by topic author guangdew1

date.png

Omar
Message 2 of 11
(5,175 Views)

Or you can try these alternatives

Match Date Regular Expression.png

Date Parser.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 11
(5,166 Views)

Hi Omar II,

 

Thank you so much for your simple and clean solution, this is exactly what I wanted. I thought it should be simple, but I just don't know how to do it.

 

Best regards,

 

0 Kudos
Message 4 of 11
(5,165 Views)

Match Regular Expression is powerful tool. Read up on it! Regular Expression

 

Mark Y. shows how to pull out the month day year as sub-matches located between ( ).

You drag the bottom of the Match Regular Expression node down to add sub-match outputs.

Omar
Message 5 of 11
(5,157 Views)

Hi Mark,

 

Thank you for your help. The first solution worked but I couldn't make the second one work. I believe I typed in correctly,

like this: ([0-9]{4,4})\.([0-9]{2,2})\.([0-9]{2,2})

 

Maybe you can explain a little about how it works so I and other people can learn something.

 

Best regards,

 

0 Kudos
Message 6 of 11
(5,156 Views)

Hi Omar II,

 

Thank you again for your help. The link is very helpful and I will try to get more into this regular expression subject.

 

Best regards,

0 Kudos
Message 7 of 11
(5,153 Views)

The {4,4} forces it to match a 4 digit string made up of the digits [0-9]. Maybe looking for a 4 digit year.

 

I think it would match something like 2011.03.11

Omar
0 Kudos
Message 8 of 11
(5,152 Views)

 


@Omar II wrote:

The {4,4} forces it to match a 4 digit string made up of the digits [0-9]. Maybe looking for a 4 digit year.

 

I think it would match something like 2011.03.11


Yes, this is what the second example is mathcing. That was an example I posted a while back and I didn't look too closely at it to see that is expecting the year first. As Omar mentioned, the {m,n} notation specifies the minimum and maximum length for the previous pattern. The {4,4} indicates it must be exactly 4 patterms in length. Something like {2,4} would match a pattern length of 2, 3 or 4. The expression {2,} would match a pattern length of 2 or more.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 11
(5,146 Views)

Hi Mark,

 

Thank you again for the help. I checked and it worked well with this date format. And it even worked when it mixed with other numbers and without space.

 

Best regards,

 

0 Kudos
Message 10 of 11
(5,141 Views)