Input String - SCON00005950
Output String - SCON-00005950
There can different scenarios for input string such as SCON00005950, SCON - 00005950, SCON- 00005950 etc. How to make sure output is always in the format i.e., SCON-00000000
Input String - SCON00005950
Output String - SCON-00005950
There can different scenarios for input string such as SCON00005950, SCON - 00005950, SCON- 00005950 etc. How to make sure output is always in the format i.e., SCON-00000000
Use Below syntax in Assign activity:
inputString = "SCON00005950"
outputString = System.Text.RegularExpressions.Regex.Replace(inputString, "\s*-\s*|\s+", "").Insert(4, "-").PadRight(13, "0"c)
Regards
It does not handle SCON-00005950,
Try this
System.Text.RegularExpressions.Regex.Match(inputString,"[A-Za-z]+").Value+"-"+System.Text.RegularExpressions.Regex.Match(inputString,"[0-9]+").Value
Cheers!!
There can be n number of scenarios for input string but output string should always be in format SCON-00000000
Your requirement is whatever may be the input you output must be SCON-00000000 the specified value only.
Regards
Correct. How to achieve that?
Here is an approach to fulfil your requirement.
strOutput="SCON-"+System.Text.RegularExpressions.Regex.Match(strInput,"\d+").Value


Sample Code:
RegexWork.xaml (6.9 KB)
Thanks,
Ashok ![]()
Is SCON a fixed value @Rohit_Nandwani
Regards
Yes, but may be lowercase sometimes
Since whatever may be your input your output should contain eight zeros I think below syntax should handle all your cases.
inputString = "scon- 00005950"
outputString = System.Text.RegularExpressions.Regex.Match(inputString, "[A-Za-z]+").Value.ToUpper() & "-" & "00000000"
Regards
Hey @Rohit_Nandwani
Welcome back to the forums.
Try this in an Assign activity:
Left:
str_Result
Right:
System.Text.RegularExpressions.Regex.Match(inputString, “(?<=SCON[\s-]*)\d+”, RegexOptions.IgnoreCase).ToString
I have considered the following examples including case sensitivity.

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