Home > Blockchain >  How to include special characters in regex?
How to include special characters in regex?

Time:12-08

I have the pattern like this:

(example:gift_card_$250,11)(example:gift_card_250,22)

I want to translate it to

col1            col2
gift_card_$250  11
gift_card_250   22

I tried this:

\((example:\w ),(\d )\)

but it misses the first entry because of the $ sign. How could I include special characters (basically everything but ,)?

CodePudding user response:

Use a character group:

\((example:[\w$] ),(\d )\)

Include any other special characters you want to match in the group.

See a regex101 demo.

  • Related