I have an information like,
AMEPVH005
AMEX1000
AMEP4712
Result:
Want the outcome as
AMEP-VH005
AMEX-1000
AMEP-4712
Cheers!
Happy Automation
I have an information like,
AMEPVH005
AMEX1000
AMEP4712
Result:
Want the outcome as
AMEP-VH005
AMEX-1000
AMEP-4712
Cheers!
Happy Automation
Try this
Say the string is stored in str then
Newstr = Str.Insert(4,"-")
Hope this helps
Cheers
Hey @Iswarya_P1 ,
You can try text.Replace(text.Substring(0,4),text.Substring(0,4)+β-β)
[Input].Substring(0, 4) + β-β + [Input].Substring(4)
if I have a information as
AMF5000
in this case, how should I add hyphens?
Cheers!
First use an if condition,
if Regex.Match(text,"[a-zA-Z]+").Value.ToString.Length
< 4,
perform text.Replace(Regex.Match(text,"\d+").Value.ToString,"-" + Regex.Match(text,"\d+").Value.ToString)
else perform text.Replace(text.Substring(0,4),text.Substring(0,4)+"-")
On what basis you want to add hyphen?
Is it not based on number of characters? If so can you tel the logic to f adding it because i see the first one you have you separater a letter as well instead of only numberβ¦
Is it like max 4 characters or till the letters are found?
Cheers
Hi @Iswarya_P1
Use the below workflow
=> Assign -> StrVar = "AMEPVH005"
=> Assign -> ReplaceValue = System.Text.RegularExpressions.Regex.Replace(StrVar.ToString,"([A-Z]{4})","-")
=> Assign -> StrVar = StrVar.Substring(0,4)+ReplaceStr
Hope it helps!!
I have information as, a combination of
AMEPVH005
AMEX1000
AMEP4712
AMF5000
Result:
Want the outcome as
AMEP-VH005
AMEX-1000
AMEP-4712
AMF-5000
The above-mentioned are possibilities,
Cheers,
Code.Length<=7
Code.Substring(0, 3) + β-β +Code.Substring(3)
else
code.Substring(0, code.Length - 3) + β-β + code.Substring(code.Length - 3)
try this If(System.Text.RegularExpressions.Regex.Match(str,"[A-Z]*").Value.Count>4,System.Text.RegularExpressions.Regex.Replace(str,System.Text.RegularExpressions.Regex.Match(str,"[A-Z]{4}").Value,System.Text.RegularExpressions.Regex.Match(str,"[A-Z]{4}").Value + "-"),System.Text.RegularExpressions.Regex.Replace(str,System.Text.RegularExpressions.Regex.Match(str,"[A-Z]*").Value,System.Text.RegularExpressions.Regex.Match(str,"[A-Z]*").Value + "-"))
cheers