This question already has answers here:
Regular expression to extract text between square brackets
(15 answers)
Closed 5 years ago.
string subject = "Re: Customer request [#11#]";
I want to fetch [#11#] from the above string. At run time instead of 11 there can be any number e.g. 12,13,14 etc.
Please suggest me appropriate Regex to fetch this output.
Something like this: \[#\d{0,}#\]
You can fiddle with it on https://regex101.com/r/uA8fX9/3
Related
This question already has answers here:
Remove dots from the path in .NET
(10 answers)
Closed 1 year ago.
Is there a built in way of removing unnessacary statements like this \hello\.. from a path in C# or do I have to do this using regex replace?
Example:
C:\Users\me\myfolder\..\anotherFolder\image.png to C:\Users\me\anotherFolder\image.png
C:\Users\me\myfolder\..\..\you\f\image.png to C:\Users\you\f\image.png
my solution using regex would be removing this /\\([^\.\\]+)\\\.\./ using a loop regexr.com
You should just be able to write this:
string fixedPath = Path.GetFullPath(#"C:\Users\me\myfolder\..\anotherFolder\image.png"));
Result in fixedPath:
C:\Users\me\anotherFolder\image.png
This question already has answers here:
What's wrong with this RegEx for validating emails?
(5 answers)
Closed 2 years ago.
I don't know anything about regex.
How do I create an email validation that allows such entries?
Allow
a1b2c3#a1b2c3
a#a
1#1
a1#a#a2e
!s#s$ds
Dont Allow
#
###
!##
Basically allow characters that has # in the middle
If you aren't fluent in regex you can split the string at "#" and expect two elements.
If you want to use regex, the first result on google was: https://emailregex.com
This question already has answers here:
Using regular expressions to validate a numeric range
(11 answers)
Closed 3 years ago.
I want to build a regex to search number in a string (using c#) with range from 0000-4095. I use this string pattern:
string regex_pattern = (0?[0-3][0-9][0-9][0-9]|{4}{0}[0-9]{0}|{4}{0}{9}[0-5]);
But i can not get success.
Can you please show me some hints?
Thanks
You could use
^([0123][0-9][0-9][0-9]|40[0-8][0-9]|409[0-5])$
Regex Demo
Sample
sorry for the multiples groups:
([0-4]0(([0-9][0-5])|([0-8][0-9])))|([0-3][0-9]{3})
Sample
This question already has answers here:
Regular expression for floating point numbers
(20 answers)
Closed 3 years ago.
I want to replace the following pattern in an html file
<BR>1696.54</TD>
to
<TD>1696.54</TD>
I am using the RegEx.Replace code
result = Regex.Replace(html, "<BR>\d</TD>", "<TD>$1</TD>")
but I am doing something incorrectly as nothing happens.
Any help would be appreciated..
You need capture a group using parentheses and change :
`\d`
to
`\d*\.\d*`
try this :
result = Regex.Replace(html, "<BR>(\d*\.\d*)</TD>", "<TD>$1</TD>")
This question already has answers here:
Is it possible to pad integers with zeros using regular expressions?
(2 answers)
Closed 9 years ago.
I am trying to display a code like ABC/DEF/00012 or ABC/EDF/01234 or ABC/DEF/00009
I use RegEx mask \w{3}/\w{3}/?????
The question mark is hard part that I could not figure it out.
Basically, I try to display the code with characters and numbers. I want to automatically add leading zeros on the number.
Byron
Seems that you're trying to match 5 digits at the end:
\w{3}/\w{3}/\d{5}