How can I split the letter and the number in the text?

How can I split the letter and the number in the text?
Forexample:
T23-> variable1: T variable2:23
AB02->variable1: AB variable2:02

Hey Try this!

For Text:

strText = System.Text.RegularExpressions.RegEx.Match(Variable1,"[A-Za-z]{0,}").ToString.Trim

Reference:

For Number:

strNumber = System.Text.RegularExpressions.RegEx.Match(Variable1,"[0-9]{0,}").ToString.Trim

Reference:

Regards,
NaNi

HI @heyium

You can try with Regex expression

 System.Text.ReguarExpressions.RegEx.Match(YourString,"[A-Za-z]*").ToString.Trim

Output -> T or AB
 System.Text.ReguarExpressions.RegEx.Match(YourString,"\d.*").ToString.Trim

Output -> 23 or 02

image

Regards
Gokul

HI,

FYI, another solution:

m = System.Text.RegularExpressions.Regex.Match(yourString,"(?<LETTER>[A-Za-z]+)(?<NUMBER>\d+)")

Then

variable1 = m.Groups("LETTER").Value
variable2 = m.Groups("NUMBER").Value

Note: m is Match class

Sample20221117-6-2net.zip (5.3 KB)

Regards,

Then I want to increase the number value by 1 but I couldn’t.

I thinks so this is a new query right? @heyium

Check out this thread

For this can you create the new topic and close this topic by mark as solved.

Regards
Gokul