RegEx Parse Entire Digits from String
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
After an incredible class at Inspire 2024 (with Albert Bellamy), I was sure I could figure out an issue I'm having with a RegEx expression. I was wrong. Maybe someone could assist.
I have a project where I'm trying to parse the digits from records in a flat file. I want the first set of digits (could range from 5 digits to 16), after the "0". However, I don't want to parse those that don't have a 3 character non-digit in the string.
For example (attached), I have the below records:
I want to extract the highlighted digits, but not the "00000000" in record 3. As you can see there are three characters in the first 2 records after the digits I want ("FFM","ADJ") - possibly use that to identify the digits I want?
Basically I want the parsed records to look like this:
The expression I'm using is "^(0)(\d{4,16})\s\s+(.+)". It gets me what I want, except it's parsing the "00000000" into the first column of my parsed records.
Thoughts?
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@karenewilkins Another regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@binuacs & @flying008 - thank you so much.
I opted for "^(0\d{4,16})(?=\s+[A-Z])(.*)$", as the three characters could be a combination of other letters other than FFM and ADJ.
This works perfectly!
![](/skins/images/6056C79A596CAB15526D64C598622101/responsive_peak/images/icon_anonymous_message.png)