问题
I have been monkeying with the following regex expression:
(\b\*)\w+(\*\b)
What I wanted to do was extract
^vitae^
from
Nam vestibulum hendrerit justo. Quisque ^vitae^ libero magna. Curabitur pretium eros ut augue ullamcorper feugiat. Aenean blandit libero vitae nunc sodales pharetra.
But what I seem to get is that regex found the text in question and returns the all of the text in the sentence as opposed to just
^vitae^
Any help would be greatly appreciated
Thanks!
回答1:
To match any text between ^
@"\^([^^]*)\^")
//matchs ^ anything that isn't ^ and finally ^
It also matches line breaks if there are any
回答2:
What about this expression:
@"\^\w+\^"
来源:https://stackoverflow.com/questions/9640051/net-regex-find-text-between-two-characters-within-a-single-or-multiple-line-b