Reputation: 832
Among other strings, I am trying to match the string LC₅₀
In VBA I am able to type superscript characters but not subscript characters.
I have the following regular expression
Dim r1 As Object
Set r1 = New RegExp
r1.Pattern = "^(\(?[a-z].*[a-z]\)?\.?,?-?:?|\(?\d{1,5}|%,?|[a-z]|LC50|\D.*³|[A-Z]\d{1},?|\(?\d{1,4}\..*\)?|°.*|[A-Z]\d(-|:).*|MPa|\(o-,|m-,|p-\))$": r1.Global = True: Set r1Matches = r1.Execute(Replace(arry(i), "- ", "-"))
My question is:
How do I match the following standalone string with a regular expression in VBA
LC₅₀
Upvotes: 1
Views: 74
Reputation: 627180
You can replace LC50
with LC[5\u2085][0\u2080]
.
With some other small enhancements, the pattern can look like
^(\(?[a-z].*[a-z]\)?\.?,?-?:?|\(?\d{1,5}|%,?|[a-z]|LC[5\u2085][0\u2080]|\D.*³|[A-Z]\d,?|\(?\d{1,4}\..*\)?|°.*|[A-Z]\d[-:].*|MPa|\([om]-,|p-\))$
Here,
\(o-,|\(m-,
is replaced with \([om]-,
[A-Z]\d(-|:).*
replaced with [A-Z]\d[-:].*
{1}
is removed, as it is always redundant.The subscript number codes are
Number | Code |
---|---|
\u2080 |
₀ |
\u2081 |
₁ |
\u2082 |
₂ |
\u2083 |
₃ |
\u2084 |
₄ |
\u2085 |
₅ |
\u2086 |
₆ |
\u2087 |
₇ |
\u2088 |
₈ |
\u2089 |
₉ |
Upvotes: 1