Sri
Sri

Reputation: 13

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

Upvotes: 1

Views: 266

Answers (2)

Alan Moore
Alan Moore

Reputation: 75232

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

Upvotes: 1

phimuemue
phimuemue

Reputation: 36031

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 ^[\$€£¥]+.*

Upvotes: 3

Related Questions