I need a regex pattern to match a sequence of 3 consecutive digits in a string that are consecutively increasing or decreasing.
For example:
These strings should match (xxx123xxx, 789xxxxxx, xxxxxx987, xxxxxx432)
These strings should not match (xxxxxx454, 333xxxxxx, xxx429xxx)
...
Suppose I have these strings:
a = "hello"
b = "-hello"
c = "-"
d = "hell-o"
e = " - "
How do I match only the -(String C)? I've tried a if "-" in something but obviously that isn't correct. Could someone please advise?
Let's say we put these strings into a list, looped through and all I wanted to extract was C. How would I do th...
I had a regex, like so:
(?<one-1>cat)|(?<two-2>dog)|(?<three-3>mouse)|(?<four-4>fish)
When I tried to use this pattern in a .Net app, it failed, because the group name contained a '-' in it.
So, as a workaround, I tried to use two regexes, the first:
(?<A>cat)|(?<Be>dog)|(?<C>mouse)|(?<D>fish)
would match the original cases I was...
Hi!
I am trying to create a proper regular expression to find all anchors in my project with Eclipse File Search.
What I'm looking for:
<a href="some.url" onclick="some onclickHandler">
What I want to accomplish is finding all anchors without an onclick and add it when needed.
Thanks for your help!
...
What I like to do is remove all functions which has specific word for example, if the word is 'apple':
void eatapple()
{
// blah
// blah
}
I'd like to delete all code from 'void' to '}'.
What I tried is:
^void.*apple(.|\n)*}
But it took very long time I think something is wrong here.
I'm using Visual Studio. Thank you.
...
I have a document with lots of <swf...>.....</swf> in it. I would like to remove all these. Using vi when i type
:%s/\<swf[^\/swf>]+\/swf\>//g
I was hoping this would work, but it doesn't match anything.
...
I am trying to create a Custom control specifically for my application which would be using maskedTextBox to restrict input data entered.
Now i want to implement this in C#.
class CustomDateMask:System.Windows.Forms.MaskedTextBox
this.Mask = "00/00/2\000"; // For year 2000 and above, date format is "dd/mm/yyyy"
this.ValidatingType = ...
I'm using an asp.net Web Forms RegularExpressionValidator Control to validate a text field to ensure it contains a series of email addresses separated by semicolons.
What is the proper regex for this task?
...
I have preg_match_all('/[aäeëioöuáéíóú]/u', $in, $out, PREG_OFFSET_CAPTURE);
If $in = 'hëllo' $out is:
array(1) {
[0]=>
array(2) {
[0]=>
array(2) {
[0]=>
string(2) "ë"
[1]=>
int(1)
}
[1]=>
array(2) {
[0]=>
string(1) "o"
[1]=>
int(5)
}
}
}
The position of o should be 4. I've read about this problem on...
First, a disclaimer. I know a little about regex's but I'm no expert. They seem to be something that I really need twice a year so they just don't stay "on top" of my brain.
The situation: I'd like to write a regex to match a certain word, let's call it "Ostrich". Easy. Except Ostrich can sometimes appear inside of a curly brace. If it...
This is super handy for some problems:
>>> re.search('(?P<b>.b.).*(?P<i>.i.)', 'abcdefghijk').groupdict()
{'i': 'hij', 'b': 'abc'}
But what if I don't know what order to expect ahead of time?
[update]
Eg, say I have an input variable containing some unknown order of characters and it just so happens that 'b' comes after 'i'. I wa...
I'm trying to write a regex to remove all but a handful of closing xml tags.
The code seems simple enough:
String stringToParse = "<body><xml>some stuff</xml></body>";
Pattern pattern = Pattern.compile("</[^(a|em|li)]*?>");
Matcher matcher = pattern.matcher(stringToParse);
stringToParse = matcher.replaceAll("");
However, when this ru...
I'm trying to get a regular expression that allows between 6 - 15 characters and can be a-zA-Z0-9 and the symbols above the numbers 1-8 on a keyboard.
Here's what I have but it doesn't work.
'/^[a-zA-Z0-9-_][\!\@\#\$\%\^&\*]{5,16}+$/'
...
I'm not sure how to use regular expressions in a function so that I could grab all the words in a sentence starting with a particular letter. I know that I can do:
word =~ /^#{letter}/
to check if the word starts with the letter, but how do I go from word to word. Do I need to convert the string to an array and then iterate through...
I know that there are many ASN.1 parser out there but they cost quite a lot and as such, I am trying to write my own.
I am kind of new to Regular Expression so in order to extract the text for the placeholders A, B, C and D, what should the Regular Expression be in C#?
A ::= B
{
C1 D1,
C2 D2,
C3 D3
}
where A, C and D can ...
I am building a user registration form using C# with .NET.
I have a requirement to validate user entered password fields.
Validation requirement is as below.
It should be alphanumeric (a-z , A-Z , 0-9)
It should accept 6-10 characters (minimum 6 characters, maximum 10 characters)
With at least 1 alphabet and number (example: stack1ove...
Using JavaScript I need to efficiently remove ~10000 keywords from a ~100000 word document, of which ~1000 will be keywords. What approach would you suggest?
Would a massive regular expression be practical?
Or should I just iterate through the document characters looking for keywords (boring)?
Edit:
Good point - only whole words, not ...
I have been banging my head against this for some time now:
I want to capture all [a-z]+[0-9]? character sequences excluding strings such as sin|cos|tan etc.
So having done my regex homework the following regex should work:
(?:(?!(sin|cos|tan)))\b[a-z]+[0-9]?
As you see I am using negative lookahead along with alternation - the \b aft...
Guys,
could you please advice how to verify in python if provided string correspond to provided pattern and return result.
For example the provided pattern is following:
< [prefix]-[id]> separated by ','>|< log >"
where prefix is any number of alphabetic characters,
id is only numbers but not exceeding 5 digits,
log is any number of ...
How can I parse multiple values from a formatted string in C#?
The string is in this format:
"blah blah blah (foo:this, bar:that)"
I need to parse out the foo and the bar value. The parentheses are always at the end of the line.
Edit: Sorry... that wasn't very clear. What I meant was I need to know the "foo" value and the "bar" v...