Reverse RegEx
- 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
Hi All,
I have the following string "stuff.my___1_year_on_practice". My Regular Expression looks like "((?:[^_]*){1})$". I am trying to Parse "practice" beginning at the end. The {1} means the last "_". Instead of "_" I want to do the last instance of any of: "abc_|def_|[0-9]_". So, for example, if my string is "stuff.my___1_year_2_practice_32", I want to match "practice_32". I think I almost have it but can someone help me get the last part working? Also, my expression creates two matches when I only want one.
Thank you so much!
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Does - ".*_(\w+_\w+)$" work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
also - you want "practice" in your first example but "practice_32" in your second example?
- 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
Hi! Yes, I'm looking for "practice" in the first example and "practice_32" in the second example. So I'm looking for a way to stick something like (?:abc_|def_|[0-9]_) into the expression, with abc and def being specific strings and [0-9] as any digit. I also want to avoid two results being matched when doing this. Thanks for looking into this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi! Just to clarify, "abc" and "def" are specific strings in my problem and the "32" in "practice_32" doesn't have to be a digit. Thanks for looking into this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
abc and def have a variety of possibilities - yes?
otherwise I'd use regex in parse mode with ".*_(abc_*\d*)$|.*_(abc_def)$" and then deal with the two columns later.
