Regular expression help

original string
asa/nata

required string
asa/n

pattern is i want to replace all the characters after the /n
meaning keeping the first charachter after “/” which is “/n” and replace all.

any suggestions pls.

Hello,
Try this :

^(.*?)/n

If it helps, please mark it as an answer so other people can see it faster

1 Like

great but my first char after “/” may not necessary be “n”

Then try this :

^(.*?)/\w{1}

It will select the slash and 1 character after it

@ANSHUL

Try this:

Str = “asa/nata”

ReqStr = Str.substring(0,Str.IndexOf(“/”)+“/”.length+1)

^(.*?)/\w{1}

this selects “asa/n”
how about if i want to remove everything after “asa/n” in “asa/nata”

@ANSHUL

Have you tried above my Expression ?

yes, but looking to remove using regular exp.

i don’t understand, you select asa/n and everything else is removed.
You want the other way around or ?

yes, want the rest to be removed.

  1. Use Match activity and store the result in a variable (create variable witch ctrl + K , lets say it name is ResultRegex)
  2. and then after it, use Assign activity and select 0 group value : StringValue = ResultRegex(0).toString

I cannot show you since i am having problem with my studio licence.

Regex2.xaml (5.0 KB)

If this is it then mark it down as a answer :slight_smile:

1 Like

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