'Regular Expression to find next word after the match

I have a statement like Data lva_var type Integer value 20. I need to find out the token after type.

My latest try was [type](?:\s\S+), but the match was e integer.

Code snippets would be helpful.



Solution 1:[1]

Just try this,
type\s(\w+)
Here the first group contains the word next to "type"
Hope this code helps.

Solution 2:[2]

You can use lookbehind for this (?<=\btype\s)(\w+) will do the trick for you. Take a look at this example.

Solution 3:[3]

JavaScript doesn't support lookbehinds, but since you tagged nsregularexpression and that does support them, maybe try this: (?<=\btype\s+)\w+

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Karthikeyan KR
Solution 2
Solution 3