regex

Regular Expression for Valid Active Directory Account Name

Does anyone have a regex that checks if a string is a valid AD account name? e.g. accounts can't have "@" and so forth. ...

Regex Expressions for all non alphanumeric symbols.

I am trying to make a regular expression for a string that has at least 1 non alphanumeric symbol in it The code I am trying to use is Regex symbolPattern = new Regex("?[!@#$%^&*()_-+=[{]};:<>|./?.]"); I'm trying to match only one of !@#$%^&*()_-+=[{]};:<>|./?. but it doesn't seem to be working. ...

Need help with really simple regular expression

I am using PHP to match the following data type : [["1200","135"],["127","13"]] I want to extract all the numbers into a seperate array of arrays like this : array(array(1200,135),array(127,13)); I am using preg_match to capture the elements but so far i am not even able to match them against a rule. I will gladly appreciate if som...

.htaccess rewrite rule preventing infinite loop

I have a directory named dollars that contains a file index.php. I would like for the url http://localhost/dollars/foo to translate to dollars/index.php?dollars=foo. This is the .htaccess file that I currently have in the dollars directorty: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !^index\.php RewriteRu...

Java regex for accepting a valid hostname,IPv4, or IPv6 address.

Anyone have a good (preferably tested) regex for accpeting only a valid DNS hostname, IPv4 or IPv6 address? ...

How to escape regular expression special characters using javascript?

Hi to all, I need to escape the regular expression special characters using java script.How can i achieve this?Any help should be appreciated. ...

Negative word matching with regular expressions

Hi, I want to be able to construct a regular expression which searches for a particular pattern in some HTML code where one parameter is negated (i.e. find x where y is NOT present). Example: I want to find image width parameters where width does not equal "500". width="640" height="360" would match width="500" height="360" would NOT...

Regular expression in javascript for restricting HTML entites like &lt;

Hii, I want to restrict the html entities like '&lt;' , "&gt;" , "&amp;"etc but it should accept '<' and '>' when i click on a button from the javascript. Can anybody gives me the regular expression for that ...

How to replace string and preserve its uppercase/lowercase

Perl question: I want to replace one string with the other; both are of the same length. I want to replace all occurrences of the string (case insensitive), but I want that the case of the letter will be preserved. So if the first letter was upper case, the first letter after the replacement will be upper case also. For example, if I w...

extract last match from string in c#

i have strings in the form [abc].[some other string].[can.also.contain.periods].[our match] i now want to match the string "our match" (i.e. without the brackets), so i played around with lookarounds and whatnot. i now get the correct match, but i don't think this is a clean solution. (?<=\.?\[) starts with '[' or '.[' ([^\[]*) ...

regular expression

?valid=true&trans_id=ABC&mpi_status_code=200&acs_url=https://www.secpay.com&amp;MD=123456&amp;PaReq=abc any one help me write an expression to get the values for acs_url and the MD using regular expressions Cheers ...

Case sensitive and insensitive in the same pattern

hi guys, thanks to the help with my previous homework question Regex to match tags like <A>, <BB>, <CCC> but not <ABC>, but now i have another homework question. i need to match tags like <LOL>, <LOLOLOL> (3 uppercase letters, with repeatable last two letters), but not <lol> (need to be uppercase). using the technique from the previou...

Matching URL with wildcards

Hi guys, I'm trying to match URLs with wildcards in them to actual URLs. For example: http://*google.com/* Needs to match http://maps.google.com And http://www.google.com/maps What would be the best way of going about this? I've tried using a regular expression and that works fine when I manually program it but I'm not sure wh...

checkstyle rule for jcip annotations

Hi, I want a rule that checks that fields and classes are properly annotated with the java concurrency in practice annotations provided by: http://mvnrepository.com/artifact/net.jcip/jcip-annotations Fields have to be annotated with @GuardedBy and classes have to be annotated with one of @Immutable, @ThreadSafe or @NotThreadSafe. I h...

Remove a comma between two specific characters

I currently have the string: "Blah, blah, blah,~Part One, Part Two~,blah blah" I need to remove the comma between the ~ character so it reads. "Blah, blah, blah,~Part One Part Two~,blah blah" Can anyone help me out please? Many thanks, ...

Why is the Alternative symbol of the ECMAScript RegExp grammar left recursive?

I cannot for the life of me figure out why Alternative is left recursive. It really throws a wrench into my parser. Alternative :: [empty] Alternative Term Here is a note in the semantics portion of the spec that is not exactly clear. Maybe the reasoning would be revealed once I understand this? NOTE Consecutive Terms ...

hashtag boundaries matching regex in javascript

I'm trying to match a set of hashtags or words in a javascript string. (#hashtag|word) almost does it, except I'd like to consider word boundaries. \b(#hashtag|word)\b doesn't match the beginning word boundary, since of course '#' is not a word character. ideally i'd like to have something like a '\b' anchor that matches hashtags...

string-manipulation - removing char from string

I currently have the following string in java: "Blah, blah, blah,~Part One, Part Two~,blah blah" I need to remove the comma between the ~ character so it reads. "Blah, blah, blah,~Part One Part Two~,blah blah" Can anyone help me out please? Many thanks, ...

Using preg_match to get filename

We use custom bbcode in our news posts [newsImage]imageName.jpg[/newsImage] And i'd like to use preg_match to get the imageName.jpg from between those tags. The whole post is stored in a variable called $newsPost. I'm new to regex and I just can't figure out the right expression to use in preg_match to get what I want. Any help is ap...

Visual Studio Find dialog non-standard regular expressions

What is the reason for Visual Studio's Find & Replace dialog regular expressions not following standard regex syntax, e.g. using :b instead of \s? ...