This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What is the best regular expression generator/explainer
Is there a way to go from a regular expression to what does it mean?
for example I found the following expression in an old code:
.*[^a-zA-Z0-9_].*
...but I do not know if this is 100% correct or if it contains any unnecessary characters?
Is there any online tool that does regular expression translation?
I use http://gskinner.com/RegExr/. You can enter both the Regex and the text you want to apply it to. It also contains a couple of samples.
Related
This question already has answers here:
Reference - What does this regex mean?
(1 answer)
Given a filesystem path, is there a shorter way to extract the filename without its extension?
(10 answers)
Closed 4 years ago.
My regex is really poor so I need help with a c# regex expression that can match a substring after the last backslash.
Typical input:
D:\DataFiles\Files_81\aars2016FAKH1800010.pdf
I need to check if the filename aars2016FAKH1A800010.pdf contains "FAKH1". It is important that only the filename is evaluated.
It must be done with C# regex, so please no "Contains"
You might be wondering why regex, but this is going to be used in a generic c# application that can evaluate regex expressions.
Thank you in advance.
You can try to use \\\w*(FAKH)\w*\.pdf pattern.
bool isExsit = Regex.IsMatch(#"D:\DataFiles\Files_81\aars2016FAKH1800010.pdf", #"\\\w*(FAKH)\w*\.pdf");
EDIT
You can use Groups[1].Value get FAKH
var result = Regex.Match(#"D:\DataFiles\Files_81\aars2016FAKH1800010.pdf", #"\\\w*(FAKH)\w*\.pdf");
var FAKH = result.Groups[1].Value;
c# online
This question already has answers here:
Returning only part of match from Regular Expression
(4 answers)
Closed 4 years ago.
I have a responce string
"c=2020&action=approvecomment&_wpnonce=7508ac918a' data-wp-lists='dim:the-comment-list:comment-2020:unapproved:e7e7d3:e7e7d3:new=approved"
Im trying to extract 2020 and 7508ac918a. I dont understand how I must use regex with substrings in C#, simple regex like
c=(\d+)&action=approvecomment&_wpnonce=(.*?)' .+new=approved.
In Regex, you can create match groups
They look like this (?.+?)
So your _wpconce part could become something like this (?.*?)
Then you can grab each group individually for example
Match result = myRegex.Match(someString);
soneOtherString = result.Groups["GROUPNAME"].Value;
I use Regex101 to build and test my regex. (Whoever made that site deserves a crown with shinny stones on it!! :)
https://regex101.com/
Hope this helps
This question already has answers here:
Get all links on html page?
(4 answers)
Closed 12 months ago.
I need to write a regular expression that scan the html code (the string) of an article in Wikipedia for links to other articles in Wikipedia.
The links usually look like these for example:
English
Spanish
I tried the regular expression: "<a.*href=(\"|')(.+?)(\"|')*wiki.*>"
it works, but it also matches links to images and not just articles.
I finally succeed. I wrote a regular expression for the beginning of the link:
(#"<a href=""/wiki/[A-Z][A-Za-z0-9\-\-_]+""")
This question already has answers here:
Capturing parts of string using regular expression in R
(3 answers)
Closed 5 years ago.
I need to parse a text file for certain information. I am using a regular expression to do so. My question is, is it possible to match an expression but only capture a relevant part, negating the need to strip the unnecessary characters after capture?
Of course, google "regex capturing groups" or check this link: https://msdn.microsoft.com/en-us/library/bs2twtah(v=vs.110).aspx#named_matched_subexpression
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
RegEx match open tags except XHTML self-contained tags
I need it
How can i get "I need it" sentence? I want use regular expression...
Here's the regex pattern that you can use to extract what you want:
(?<=\<a\shref=.*?\>).*?(?=\<\/a\>)