G
Guest
Hi,
does anybody know I can extract a substring of a text with regular expressions. Let’s consider the following text: “Regular expressions are often used to make sure that a string matches a certain pattern.â€.
I e.g. want to extract everything between “expressions†and “a†which is in the above example “are often used to make sure thatâ€.
The unfortunately best I could do was the following piece of code:
Dim myRegularExpression As New System.Text.RegularExpressions.Regex("expressions[\s\S]*\sa\s")
myMatch = myRegularExpression.Match("Regular expressions are often used to make sure that a string matches a certain pattern.")
Console.WriteLine(myMatch.Value)
which lead to the following result:
"expressions are often used to make sure that a string matches a "
Unfortunately my RegEx takes the last “a†in the text string but I want it to recognize the first appearance of “aâ€.
Does anybody have a clever idea?
Thank you!
Daniel Walzenbach
does anybody know I can extract a substring of a text with regular expressions. Let’s consider the following text: “Regular expressions are often used to make sure that a string matches a certain pattern.â€.
I e.g. want to extract everything between “expressions†and “a†which is in the above example “are often used to make sure thatâ€.
The unfortunately best I could do was the following piece of code:
Dim myRegularExpression As New System.Text.RegularExpressions.Regex("expressions[\s\S]*\sa\s")
myMatch = myRegularExpression.Match("Regular expressions are often used to make sure that a string matches a certain pattern.")
Console.WriteLine(myMatch.Value)
which lead to the following result:
"expressions are often used to make sure that a string matches a "
Unfortunately my RegEx takes the last “a†in the text string but I want it to recognize the first appearance of “aâ€.
Does anybody have a clever idea?
Thank you!
Daniel Walzenbach