Regular expression1

I have text following as
patients(normal text).1,2(it as superscript)
how do i write regex to find the whether the text contains superscript.Kindly help

Thanks
Samsanditha BP

@Samsanditha
I dont use mach of regex.But you can use contains method to check if it is contais of superscript! Just use String.Contains(“Value”)

cheers :smiley:

Happy learning :smiley:

2 Likes

Open charnap in Windows and find the superscript char 1 and 2. Copy the character and use it as your value for indexOf function to check if it exists.

If myString.indexOf(“¹”)>-1 then character exists.

Here you go
If input is
str_input = “patients(normal text). 1,2 (it as superscript)”
Then In a assign activity like this

Bool_output = System.Text.RegularExpressions.Regex.IsMatch(str_input,”(superscript)”, RegexOptions.IgnoreCase)

Cheers @Samsanditha

1 Like

hello @Samsanditha

if i am not wrong if you read any text file or string value, results will be a plan text (string).
then you can simply go with .contains() method to proceed your validation.

also if you can give some examples to know how input string look like then can look for regex.

Regards
Ajay

Thanks for the response…But even there are text in this format also 1^1.then how can you pass the value because base and power are similar.Even the power value keeps fluctuating.

@Samsanditha

if you have text like 1^1 then following regex may help

regex = (\d*)(\^)(\d*)
which matches zero or more digits(0-9) followed by a ^ char and followed by zero or more digits(0-9) like 123^2

Regards
Ajay

Thanks.but the superscript value keeps fluctuating from one sheet to another

Regards
Samsanditha

Thanks for the response.if the base is text or space and superscript is numeric then how to write the expression.Eg:population³ or(Space)³˒²

Regards
Samsanditha

Thank you.will check this one

Regards
Samsanditha

1 Like

Please try this.
Superscript.xaml (5.4 KB)

Thanks for the workflow.But there are few text in the word eg:(population)².how to identify

Regards
Samsanditha

Please try to change the regex value to this --> “(A-Za-z0-9_)*\p{No}”

1 Like

@Samsanditha the regex which @rvegafria mentioned works as you expected
i just did some modification based on your example

\p{No}*(\([A-Za-z0-9]*\))\p{No}*

Regards
Ajay

1 Like