03-11-2011 09:12 AM
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.
Solved! Go to Solution.
03-11-2011 09:51 AM
03-11-2011 10:03 AM
Or you can try these alternatives
03-11-2011 10:04 AM
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,
03-11-2011 10:21 AM
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.
03-11-2011 10:22 AM
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,
03-11-2011 10:26 AM
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,
03-11-2011 10:26 AM
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
03-11-2011 10:44 AM
@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.
03-11-2011 11:03 AM
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,