开发者

RegEx: how to find whether a text begins with currency symbols?

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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜