I would like 开发者_运维问答to check whether a given text begins with some currency symbols, like $€£¥. how to achieve that using regex
Depending on your language, but something like ^[\$€£¥].*
[]
is a character group matching one of the characters inside.
You might have to write \$
because the $
-sign has sometimes special meaning in regexps.
.*
matches "everything else" (except a newline).
Edit: After re-reading your question: If you really want to match some currency symbols (maybe more than one), try ^[\$€£¥]+.*
Which regex flavor? If it's one that supports Unicode properties, you can use this:
^\p{Sc}
(I didn't add quotes or regex delimiters because I don't know which flavor you're using.)
精彩评论