Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm new to regex but it looks as though this will work for what I need, but I just can't get my head around it.
I have a string "MAMMOTH 9MM" as an example.
All should stay upper case except the specified chars of "MM" after any digit.
Should be simple?
You can look for regular expression patterns and apply a lambda function to modify the matches:
input = Regex.Replace(input, #"(?<=\b[0-9]+)MM\b", m => m.ToLower())
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a string input which looks like:
var price = "£1.33(including postage)";
I'd like to take out the first part of the string before ( so that the output of regex would look like this:
"£1.33"
I'm new with Regex so I'm not quite sure how to do this, can someone help me out?
P.S. I thought of doing a substring, but that wouldn't work since price can have more decimals, and can be a larger price, so this option definitely wouldn't work
do you have to use regex?
much easier if you use split
string result = price.Split('(').First();
You don't need Regex for this if you have the same basic format of the "price" just different values.
var result = price.Substring(0, price.IndexOf("("));.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to perform a search to C# list object to find all products starts with any number or special characters only. I am looking for a Regular expressions for this scenario.
Please help
Assuming you list is a list of string:
var newList = yourList.Where(element => Regex.IsMatch(element, #"^[^a-z]", RegexOption.IgnoreCase);
It will give you a sublist of all the elements that doesn't start with a letter in the range a-z.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a sentense as below:
"I.UILISTNConsolidatedGroup: 8000Quarte: AnnualUnit: USD" or
"I.UILISTNDOUxConsolidatedGroup: 8000Quarte: FullUnit: VND"
I have to separate into 4 values from the sentence above: I.UILISTN, 8000, Annual, USD. I'm using index of to separate that, but it's seem so long and complex, please help me separate these values by regular expression (c#).
The words ConsolidatedGroup, Quarte, Unit are fixed.
Thanks in advance!
Manual matching are almost always be faster then Regular Expressions.
string text = "I.UILISTNConsolidatedGroup: 8000Quarte: AnnualUnit: USD";
Regex regex = new Regex(#"([\w\.]+)ConsolidatedGroup: (\d+)Quarte: AnnualUnit: (\w+)");
var match = regex.Match(text);
foreach (var m in match.Groups)
{
Console.WriteLine(m);
}
Output:
I.UILISTNConsolidatedGroup: 8000Quarte: AnnualUnit: USD
I.UILISTN
8000
USD
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hei Guys
I got the regex for my software and it works. I only need the pattern that I will write between (" ") these. Thank you guys
The seperator should be a , or a .
Try this: '\d' for number, '\d+'for more numbers before ',' ...
\d+(,\d\d?)?
or
\d+(,\d{1,2})?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
[code]>
10 /td>[/code]
I want to get 10 from this line. But I need to preserve the pattern. How can I write an expression that gets:
, newline, ignorewhitespace OR included indeterminate spaces, 10, ignorewhitespace OR included all space, /td
Thanks,
JOe K.
Ok, I'll be nice and help you this time. =)
I assumed that the number you are looking for can change.
var result = Regex.Match(
"[code]> 101 /td>[/code]",
#"(?<=\>\s*)\d+(?=\s*/td\>)").Value;
But please, try doing it the next time... I'll point you a tool that could help in designing and learning Regex:
http://www.radsoftware.com.au/regexdesigner/