I am looking for regular expression in java that matches the following pattern:
two alternating numeric or alpha values Example: 12121212 or adadadad
numeric or alpha sequences with at least 4 sequential digits Example: cdefgh or 123456
thanks
...
On my registration page I need to validate the usernames as alphanumeric only, but also with optional underscores. I've come up with this:
function validate_alphanumeric_underscore($str)
{
return preg_match('/^\w+$/',$str);
}
Which seems to work okay, but I'm not a regex expert! Does anyone spot any problem?
...
I am having problems using a ASP.NET Regular Expression Validator on text boxes.
This is a condensed version of my code:
RegularExpressionValidator regex = new RegularExpressionValidator();
regex.ID = "TextBoxRegExValidator" + ((AVPEditControl)avpControl).ThisFieldRID.ToString(); //random name
regex.ControlToValidate = ((AVPEditC...
Hello,
Doing regex in C# or PHP is very easy for me now. However currently I have a need to use regex in C. And, I don't seem to understand the usage of regcomp or regexec fully. It's definitely because of my lack of experience in C.
Any help and examples would be much appreciated!
...
My program can accept data that has newline characters of \n, \r\n or \r (eg Unix, PC or Mac styles)
What is the best way to construct a regular expression that will match whatever the encoding is?
Alternatively, I could use universal_newline support on input, but now I'm interested to see what the regex would be.
...
I've been struggling with getting a working regular expression for a little project of mine. Can anyone help me with a regex that matches anything inside <> symbols, but only when they are not preceded by a \ symbol?
For example:
<Escaped characters \<\> are right in the middle of this sentence.>, <Here is another sentence.>
Must mat...
Hello,
I'm parsing a large text file using PHP and some lines look like this "äåòñêèå ïåñíè", or "ääò", or like this "åãîð ëåòîâ". Is there any way to check if there are more than three characters like this in string?
Thank you.
...
I am parsing documents which contain large amounts of formatted numbers, an example being:
Frc consts -- 1.4362 1.4362 5.4100
IR Inten -- 0.0000 0.0000 0.0000
Atom AN X Y Z X Y Z X Y Z
1 6 0.00 0.00...
Hi folks,
I would like to negate a set of words using java regex.
Say, I want to negate cvs, svn, nvs, mvc. I wrote a regex which is ^[(svn|cvs|nvs|mvc)].
Some how that seems not to be working. Could you please help? Thanks.
.\J
...
I have a textarea field on my webpage. I am accepting the user input, I want to parse that user input for "(SEPARATED BY COMMAS, SPACES, OR ONE PER LINE)" this line.
Basically I want to fetch the words, seprated by comma, space or one per line. What can be the RegEx for this which I can use like below:
preg_split('/[,; " "]+/', $_tags...
Consider the following Javascript regular expression matching operation:
"class1 MsoClass2\tmsoclass3\t MSOclass4 msoc5".match(/(^|\s)mso.*?(\s|$)/ig);
I would expect it to return [" MsoClass2\t", "\tmsoclass3\t", " MSOclass4 ", " msoc5"]. Instead it returns [" MsoClass2\t", " MSOclass4 "].
Why?
...
Hi there!
For my users I need to present a screen where they can input multiple domain names in a textarea. The users can put the domain names on different lines, or separate them by spaces or commas (maybe even semicolons - I dont know!)
I need to parse and identify the individual domain names with extension (which will be .com, anyth...
I need to strip all xml tags from an xml document, but keep the space the tags occupy, so that the textual content stays at the same offsets as in the xml. This needs to be done in Java, and I thought RegExp would be the way to go, but I have found no simple way to get the length of the tags that match my regular expression.
Basically w...
I noticed that Feedzirra uses this regex to get the ETag from response header:
/.*ETag:\s(.*)\r/
Personally I would have written this one:
/ETag:\s(.*)\n/
Here the questions:
Why does it put .* at the beginning even if it is unnecessary (\A is not specified)?
Why does it use \r instead of \n? What is the difference?
...
I need to extract the zip code from a string. The string looks like this:
Sandviksveien 184, 1300 Sandvika
How can I use regex to extract the zip code?
In the above string the zip code would be 1300.
I've tried something along the road like this:
Regex pattern = new Regex(", [0..9]{4} ");
string str = "Sandviksveien 184, 1300 Sandvi...
I'm having trouble getting my regex to work (big surprise)
I'm trying to replace urls in a large body of text:
<img src="http://www.example.com/any/number/of/directories/picture.jpg" ...
<img src="http://www.example.com/any/number/of/directories/picture.gif" ...
With:
<img src="/LocalDirectory/images/picture.jpg" ...
I want to ma...
I am trying pull a field out of a string and return it.
My function:
public function getSubtype(ut:String):String {
var pattern:RegExp = new RegExp("X=(\w+)","i");
var nut:String = ut.replace(pattern, "$1");
trace("nut is " + nut);
return nut;
}
I'm passing it the string:
http://foo.bar.com/cgi-bin/ds.pl...
If I have a string like this:
$str = "blah blah blah (a) (b) blah blah blah";
How can I regex so that the output is:
$str = "blah blah blah blah blah blah";
Needs to be able to support any number of bracket pairs inside a string.
Thanks for any answers!
...
I'm looking to accept values of (6 chars long or nothing).
This is for an update form. If a password is entered, I'd like to force 6 chars long. If not, I want to ignore the field.
Here's a REGEX that gets me the 6 char part, any help on handling empty also?
<asp:RegularExpressionValidator id="rev1" runat="server" SetFocusOnError=...
I am trying devise Perl regex to parse command output from IBM's runmqsc utility.
Each line of output of interest contains one or more attribute/value pairs with format: "ATTRIBUTE(VALUE)". The value for an attribute can be empty, or can contain parenthesis itself. Typically, a maximum of two attribute/value pairs appear on a given li...