开发者

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

开发者 https://www.devze.com 2023-01-08 21:19 出处:网络
I would like 开发者_运维问答to check whether a given text begins with some currency symbols, like $€£¥. how to achieve that using regexDepending on your language, but something like ^[\\$€£¥].*

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

精彩评论

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