简体   繁体   中英

Regex that Detects specific string pattern

I'm new to Regex. The question asks me, Come up with a Regex that Detects specific string whether in start, middle or end of a string with Regular Expressions?
Try it yourself before checking the solution below:

I first thought the solution would be this:

  (?:^\s+)|(?:\s+$)

The solution is this:

  (?:\s|_)ra(?:\s|_) 

How does this Regex work?

Can you walk me through each step? What does this line of Regex do? Please help me out.

I was able to find answer to my question. I will close the post now.

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