-1

I'm trying to use Regex to match everything after the double occurrence of an underscore in the following string: ABCD__A123. My desired output would be A123.

I currently have /__(.+)/ which produces an output that includes the double underscore. I've searched all over SO and Google for answers with no luck!

danw
  • 1,608
  • 4
  • 29
  • 48
  • 2
    Oh, you have not searched for a *positive lookbehind*, have you? BUT what is the regex flavor (programming language/tool)? Do you really need a lookbehind? You can get the captured value using your pattern. – Wiktor Stribiżew Apr 06 '16 at 13:51
  • I guess DataWeave. Then please read this: [*The `match` operator returns an array of matches that contains the entire matching expression, followed by **all of the capture groups that match the provided regular expression**. In this case `($ match /([A-Z]{2,4})\d*/)[1]` will return the code which will be in the first and only capture group for those identifiers it matches.*](http://blogs.mulesoft.com/biz/mule/getting-started-with-dataweave-part-4/). So, your regex works as you need, you just need to access the `[1]` value. – Wiktor Stribiżew Apr 06 '16 at 14:07
  • @WiktorStribiżew yes DataWeave, thank you for your response. – danw Apr 06 '16 at 14:11
  • I see, but the answer accepted and the fact that you did not provide the regex flavor make your question a duplicate. – Wiktor Stribiżew Apr 06 '16 at 14:13

1 Answers1

2

Try positive lookbehind like this.

Regex: (?<=__).+

Regex101 Demo