Pattern: Unicode characters
“Unicode characters” is one of the patterns that you can select on the Match panel. Use this pattern to restrict a field to a certain set of Unicode characters. The repetition settings for the field determine how many characters the field can or must match.
This example shows how you can use the “Unicode characters” pattern to match a currency symbol. You can find this example as “Pattern: Unicode characters” in the RegexMagic library.
- Click the New Formula button on the top toolbar to clear out all settings on the Samples, Match, and Action panels.
- On the Samples panel, paste in one new sample:
Some of the world's major currency symbols are $, €, ¥, and £.
- On the Match panel, set both “begin regex match at” and “end regex match at” to “anywhere”.
- Click the button to add field .
- In the “pattern to match field” drop-down list, select “Unicode characters”.
- In the “Unicode categories” list, tick the “currency symbols”.
- On the Regex panel, select “C# (.NET 2.0–8.0)” as your application, turn off free-spacing, and turn off mode modifiers. Click the Generate button, and you’ll get this regular expression which matches a single character that is considered to be a currency symbol by the Unicode standard:
\p{Sc}
Unused options: Case sensitive; Exact spacing; Dot doesn’t match line breaks; ^$ don’t match at line breaks; Numbered capture.
- The Samples panel now shows the regular expression finds 4 different matches in our sample text:
Some of the world's major currency symbols are $, €, ¥, and £.
Related Examples
Reference