Quick Regex Help
Hey All,
A Coworker of mine is trying to learn a little more about regex and asked me for some help when he was working on an exercise on a training site and it looks like the exercise is broken to me and wanted to get another set of eyes to take a look and make sure im not just missing something. Here is the data set: Code:
task text capture result Code:
(^\d{4}(*\d$)) The exercise leads me to believe that there is an issue with the subgroup setup but it looks right as either part of that regex will match the half he wanted. Obviously I'm not a regex expert and use it very rarely but this looks like it should work. Update: Almost 100 views and 0 replies. Does this regex really stump everybody out there? :P Thanks. |
Quote:
- In which way is this regexp used? Not all commands are able to use regexp's the same way. Is this regexp a part of perl, sed or theoretical? - The data set you provide doesn't look like an input file, but more like a combined input/output. You might want to provide the an input file and desired output. Or even better: copy/paste the original question that was asked during the training session. |
What exactly are you trying to capture?
^ matches the start of the line, and $ matches the end. The given regex will not match any lines in the given data set. You seem to be trying to match digits, so if you want to pull out the 'text' column, try this: Code:
(\d{4}x\d{3,4}) |
After coming back and reading some of the suggestions here I was able to get the right exp there, the idea was to capture the two sets of digits in sub groups:
Code:
(\d{4})x(\d{3,4}) |
All times are GMT -5. The time now is 03:15 PM. |