最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Regular Expression to find next word after the match - Stack Overflow

programmeradmin11浏览0评论

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.

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.

Share Improve this question edited Sep 20, 2016 at 16:18 Alan Moore 75.2k13 gold badges107 silver badges160 bronze badges asked Sep 9, 2016 at 13:24 AKHIL RAJAKHIL RAJ 781 gold badge2 silver badges4 bronze badges 3
  • 1 You've tagged this with three different languages/environments - where do you need the Regex? – vwegert Commented Sep 9, 2016 at 13:55
  • I need a general regular expression – AKHIL RAJ Commented Sep 9, 2016 at 14:04
  • You misunderstand the question - which language will you be using this regular expression in? They vary, and you've marked it in two specific / different languages. Which is it? – random_user_name Commented Sep 9, 2016 at 15:20
Add a comment  | 

3 Answers 3

Reset to default 7

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

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

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

发布评论

评论列表(0)

  1. 暂无评论