Getting the text that follows after the regex match

后端 未结 5 1737
你的背包
你的背包 2020-11-22 11:33

I\'m new to using Regex, I\'ve been going through a rake of tutorials but I haven\'t found one that applies to what I want to do,

I want to search for something, but

5条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 12:03

    You can do this with "just the regular expression" as you asked for in a comment:

    (?<=sentence).*
    

    (?<=sentence) is a positive lookbehind assertion. This matches at a certain position in the string, namely at a position right after the text sentence without making that text itself part of the match. Consequently, (?<=sentence).* will match any text after sentence.

    This is quite a nice feature of regex. However, in Java this will only work for finite-length subexpressions, i. e. (?<=sentence|word|(foo){1,4}) is legal, but (?<=sentence\s*) isn't.

提交回复
热议问题