Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

string - Regex to match one or more characters

I need to filter a set of strings with a wildcard-type search, like the following:

  • Looking for He*lo should match "Hello", but not "Helo"
  • Looking for *ant should match "pant" and "want" but not "ant"
  • Looking for *yp* should match "gypsy" and "typical"

The * represents one or more characters. I don't mind a handwritten or regex-based search. Any ideas? The typical .NET approach for wildcards matches 0 or more, but I need 1 or more characters. How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What you're looking for is the + regex operator


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...