I use the following regex, but it doesn’t work
([^@]+)(?:_@(\d+))?
Variable_Name_1
Actual:
\1 = Variable_Name_1
\2 = nullExpected:
\1 = Variable_Name_1
\2 = null
Variable_Name_1_@4
Actual:
\1 = Variable_Name_1_
\2 = null
Expected:
\1 = Variable_Name_1
\2 = 4
Do you have some ideas to solve my problem ?
If that’s the only requirement, regular expressions are overkill. How about this instead: