Reputation: 33
Am using this tutorial to create regular expression for one of my task with input string as:
[Begin] { (GetLatestCode)
Trying to extract string between brackets i.e. trying to extract GetLatestCode for which I made the following:
(?<=\[Begin\]\s{\s\()\w+(?=\)) //returns GetLatestCode
But this solution does not seem to work when I have multiple spaces around the curly brace.
[Begin] { (GetLatestCode) //does not work
Upvotes: 0
Views: 44
Reputation: 1934
If you need to account for 0 or more spaces, add a *
after each space:
(?<=\[Begin\]\s*{\s*\()\w+(?=\))
If you need to account for 1 or more, use a +
:
(?<=\[Begin\]\s+{\s+\()\w+(?=\))
Upvotes: 1