Regex - for an string

Hi, can anyone help with the regex for this string:
Loan Info Loan ID contains "6600dd89-af75-4d1e-85e6-e9abc2cd383f"\r\n"

I need the string in between the double quotes. (it can start with a number or an alphabet)

Loan Info Loan ID contains "6600dd89-af75-4d1e-85e6-e9abc2cd383f"\r\n"

Thanks

This is a very standard regex for capturing a guid: ^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$

1 Like


Pattern: (?<=").*(?=")

1 Like

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"[^""]+").Value

or

System.Text.RegularExpressions.Regex.Match(yourString,"[A-Za-z0-9][-A-Za-z0-9]*").Value

Regards,

1 Like

Its giving me the first part of the string:

Hi @chauhan.rachita30,

I am sharing it as an alternative solution. I hope it works for you.

According to this solution, it is assumed that the first unit of the string consists of 4 digits.

value = “6600dd89-af75-4d1e-85e6-e9abc2cd383f”\r\n"

valueArray=value.Split("-"c)

value=value.ToString.Substring(valueArray(0).Length-4,valueArray(0).Length).Split(Chr(34).ToString.ToArray)(0)

Regards,
MY

1 Like

Hi @chauhan.rachita30

You likely have a solution already but i’ll throw in one more.

Regex Pattern:
(?<=Loan ID contains .)[a-zA-Z0-9\-]+

Hopefully this helps

Cheers

Steve

1 Like

Hi,

Sorry, I had misunderstanding for input string.
Can you try the following?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<="")[^""]+(?="")").Value

Regards,

1 Like

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