How to get only Numbers and Symbol from a string

Hi i need to extract only the number and symbol from a string

example
Input : “ISP202032667-12.pdf”
Output : “202032667-12.pdf”

Thnks

Hi @Ahmad_Rais

Please use the following RegEx pattern:

(?<=ISP)\d+-\d+\.pdf

image

Hope this helps,
Best Regards.

system.text.regularexpression.regex.match(input,“[\d-]+”).value

image

1 Like

Hi @Ahmad_Rais
Try using below Regex Expression:

[\d-](.*)


Hope it helps!!
Regards

Hi @Ahmad_Rais

Use the regular expressions for the required output. Check the below regular expression.

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((?<=[A-Z]+)\d.*)”)

image

Hope it helps!!

Hi,

If you need to keep extension and remove alphabet in filename without extension, the following will work.

System.Text.RegularExpressions.Regex.Replace(System.IO.Path.GetFileNameWithoutExtension(yourString),"[A-Za-z]","")+System.IO.Path.GetExtension(yourString)

Regards,

2 Likes

Hi @Ahmad_Rais

Try this-

  1. Use the “Assign” activity to define a regular expression pattern. Let’s assume you want to extract numbers and symbols, so the pattern will be [^a-zA-Z]+.
  2. Use the “Matches” activity to find all occurrences of the pattern in the input string. Set the “Input” property to the string you want to extract from, and the “Pattern” property to the regular expression pattern defined in step 1.
  3. Access the extracted values by iterating through the collection of matches using a “For Each” activity.
  4. Concatenate the matched values to form the desired output string.

Thanks!!

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