I need to get text from a string

“ACN - Test Number & Test Channel Statements 15.09.23”… I want to get Test Number , Test Channel from this string. Can someone help to do this ?

@ajnaraya ,
Can you please elaborate? Like
Input : _______
Output :________

Regards,

2 Likes

Hi @ajnaraya

Try this

(?<=\-\s+).*(?=\s+\&\s+)|(?<=\&\s+).*(?=\s+Statements)

1 Like

“ACN - Test Number & Test Channel Statements 15.09.23” Input
Test Number , Test Channel is the output i want


Hope this helps
Usha

1 Like

@ajnaraya

1 Like

@ajnaraya ,
If the Sentences are similar for all the cases you can make use of below methods

TestNumberOutput = Split(Split(“InputVar”,"ACN-")(1),"&")(0).trim

TestChannelOutput = Split(Split("InputVar","&")(1)," Statements")(0).trim

Regards,

1 Like

Have you tried this ? @ajnaraya

Seems like it is working fine for me

Regards
Sudharsan

Hi @ajnaraya

You can use the below regular expressions to extract the required output from the Input data.

- Assign -> Input = "ACN - Test Number & Test Channel Statements 15.09.23"
- Assign -> Output = System.Text.RegularExpressions.Regex.Matches(Input.ToString,"((?<=&\s+|\-\s+)[A-Za-z]+\s+[A-Za-z]+)")

Check the below image for better understanding.

Hope it helps!!

1 Like

@ajnaraya

TestNumber=System.Text.RegularExpressions.Regex.Matches(str,“(?<=ACN\s.\s)\b\w+\s\w+|\w+\s\b.*(?=\sStatements)”)(0)

TestChannel=System.Text.RegularExpressions.Regex.Matches(str,“(?<=ACN\s.\s)\b\w+\s\w+|\w+\s\b.*(?=\sStatements)”)(1)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.