简体   繁体   中英

Regex to find word starting and ending with ##

I am using ##\\b\\S+?\\b## regex to find word starting and ending with ## which finds the below,

##YourFriend##

This does not work when there is a space in between words like

##Your Friend##

I need a regex which works for both the cases, that could find both,

 ##YourFriend##
 ##Your Friend##

I tried using \\s which is used to find the white spaces, but it does not work.

You can use this: ##.*?## .

Which will match the two ##s in a non greedy way.

Use this: ##(.*?)## . '()' is for grouping the matched value.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM