Error with one String Expression

hi Team,

I/P : A#B#c###D####
Expected O/P : A,B,C,D

i tried something like this but getting error.

any suggestions or any Regex we can use for the same.

@devasaiprasad_K

Try this

string.Join(",",inputstr.Split("#"c).Where(Function(a) not string.IsNullOrEmpty(a.ToString)).ToArray)

Hi @devasaiprasad_K

Change the both expressions as below,

- Assign -> outRes = InputVal.Replace("#"," ")

and

String.Join(",", outRes.Split(" "))

Hope it helps!!

Hi @devasaiprasad_K ,

Could also check with Regex Replace :

System.Text.RegularExpressions.Regex.Replace("A#B#C###D####","#{1,}",",").Trim(",".ToCharArray)

image

1 Like

Hi @devasaiprasad_K

Try this

String.Join(", ", System.Text.RegularExpressions.Regex.Matches(Input,"\w+"))

Cheers!!

1 Like

what exactly #{1,} does

Hi @devasaiprasad_K

Plese try with this
String.Join(β€œ,”, inputString.Where(Function(c) Char.IsLetterOrDigit(c)).Select(Function(c) Char.ToUpper(c)))


image

Hi Devasaiprasad K,

Try this : System.Text.RegularExpressions.Regex.Replace(Input, β€œ#+”, β€œ,”).Trim

what exactly #{1,} does

Could try the below one,

- Assign -> Input = "A#B#C###D####"

- Assign -> Output = String.Join(",", Input.toString.Split("#"c).Where(Function(x) Not String.IsNullOrEmpty(x)).ToArray())

Check the below workflow for better understanding,

Hope it helps!!

@devasaiprasad_K ,

Apologies for the late reply.

#{1,} is basically a regex expression, which matches one or more occurrences of the character #.

We could check the expression meaning in bit more expressed terms with some regex websites like below :

1 Like

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