Match two strings A and B. The middle of the string contains A and B:
Expression: A.*?B ("." means any character, "?" means 0 or more matches)
Example: Abaidu.comB
result : Awww.apizl.comB
matches two strings A and B. The string between A and B contains A but does not contain B:
Expression: A.*?(?=B)
Example: Awww.apizl.com B
Result: Awww.apizl .com
matches the string between the two strings A and B and does not contain A and B:
Expression: (?<=A).*?(?=B)
This kind of writing is not understood, I guess it is if it does not Contains the previous matching character writing (? <= the beginning character to be matched), but does not include the subsequent character writing (? = the ending character to be matched)
Example: A www.baidu.com B
Result: www.baidu.com
Regular expression matches the middle content of the specified string
Guess you like
Origin blog.csdn.net/weixin_43452467/article/details/113884408
Recommended
Ranking