regex

Remove IP address from Query String using HTACCESS

I have a URL like so: http://example.com/one/?ACT=123&gateway=mygateway&method=mymethod&orderID=303&currency=EUR&amount=11&PM=CreditCard&ACCEPTANCE=test123&STATUS=9&CARDNO=XXXXXXXXXXXX1111&ED=0517&CN=Test+test&TRXDATE=08%2F12%2F10&PAYID=7963938&NCERROR=0&BRAND=VISA&ECI=7&a...

Validating UK Post Codes using regular expressions.

I want to validate a field with a UK Post Code. What regular expression could be used to validate this field?. (([A-Z]{1,2}[0-9][0-9A-Z]{0,1})\ ([0-9][A-Z]{2}))|(GIR\ 0AA)$ does appear valid because it has the exception GIR 0AA. So, please help me to write an expression without any exception ...

how to enter only character in Regex - C# ?

hi i have textbox and i need to check if he contain only character how to do it with Regex in C# ? thank's in advance ...

Regex and the characters case.

Okay, I got a rather simple one (at least seems simple). I have a multi lined string and I am just playing around with replacing different words with something else. Let me show you... #!/usr/bin/perl -w use strict; $_ = "That is my coat.\nCoats are very expensive."; s/coat/Hat/igm; print; The output would be That is my Hat Hats are ...

Make new string from old string, C#

Input: X(P)~AK,X(MV)~AK Expected Output: P(curr=AK),MV(curr=AK) Using C#3.0 I solved by using string functions(split,then appending etc.) Looking for more niche solution(like regular expression) Thanks ...

Javascript regex to reject non ASCII-US characters

^[^\x00-\x1F\x7F-\xFF]+$ This regex will properly fail to match a string that contains non-printing (hex 00-1f) or ASCII extended characters (hex 80-FF), but, unlike PHP, lets non-ASCII utf-8 characters pass. (eg. 日本واستقرارهहिन्दीދިވެހިބަސްગુજરાતી한) Looking at the wikipedia page on UTF-8 all of those should fall in the 80-ff range. ...

Regex help: replacing all matches except the first one

I have a malformed URL like this: http://www.abc.com/?abc&?as&?blah Now, I want to match (and eliminate) all "?" in the URL except the first one to make the URL clean. Is it possible using Regex? I tried positive look behind and other methods, but it didn't work for me. PS: I need to do this regex operation in JavaScript ...

Regex to remove div tags but not their content

Let's say this is my HTML: <ul> <li><div style="width: 10em;">Hello</div><div class="ble"></div></li> </ul> I want to get this: <ul> <li>Hello</li> </ul> As you can see, all div opening and closing tags were removed but not their content! This is what I have so far: $patterns = array(); $patterns[0] = '/<div.*>/'; $patter...

How can I enable the user to enter reserved characters into the database with a combination of PHP, MySQL and AJAX?

Hi, I've set up a website that allows the user to add places to a database. However, I am unfamiliar with regex and so I'm not sure how to allow characters like apostrophes and dollar signs without them affecting the database INSERT. I have a form, which is read by AJAX and processed with PHP/MySQL so there's thee languages which have t...

Alternating chars and nested parenthesesin (e)grep

I'm looking for a regex that finds all words in a list that do not have characters next to each other that are the same. (this is an exercise) So abcdef is printed, but aabcdef is not. I tried both egrep "^((.)[^\1])*$" and egrep "^((.)[^\2])*$" words but, other than being not sure which one would be right, they don't work. I k...

Complex password Regular expression

Hi, I have the following criteria for creating a regular expression for a password that conforms to the following rules: The password must be 8 characters long (this I can do :-)). The password must then contain characters from at least 3 of the following 4 rules: Upper case Lower case Numbers Non-alpha numeric I can make the e...

Regex replacement capture followed by digit

I am trying to get a Regex replacement working to update my AssemblyInfo.cs files, so I have: Regex.Replace( contents, @"(\[assembly: Assembly(File)?Version\("").*(""\)\])", "$1" + version + "$3" ); The problem is that version is something like "1.5.3.0", so that when the replacement is evaluated it is seeing "$11.5.3.0$...

How to pass object_id to generic view object_detail in Django

I'm using django.views.generic.list_detail.object_detail. According to the documentation the view takes the variable object_id. To do this I added the following to my urlconf: (r'^(?P<object_id>\d+)$', list_detail.object_detail, article_info), The above line is in a separate urlconf that is included in the main urlconf. If I leave t...

RegEx to grab an entire div with a specific ID?

Hi There, I have some markup which contains the firebug hidden div. (long story short, the YUI RTE posts content back that includes the hidden firebug div is that is active) So, in my posted content I have the extra div which I will remove server side in PHP: <div firebugversion="1.5.4" style="display: none;" id="_firebugConsole"></di...

need a regular expresion to validate started double quote is ended or not

Need a regular expression to validate a double quote(") is started and it must to be ended. Example : "This is valid" but "This is not valid ...

regex: put text outside <p> inside <p>

I have some broken html-code that i would like to fix with regex. The html might be something like this: <p>text1</p> <p>text2</p> text3 <p>text4</p> <p>text5</p> But there can be much more paragraphs and other html-elements too. I want to turn in into: <p>text1</p> <p>text2</p> <p>text3</p> <p>text4</p> <p>text5</p> Is this poss...

How can I extract a script tag from some text using Regex?

I don't know Regex very well, and I'm trying to get all of the script tags from some extracted page text. I've tried the following pattern: <script.*?>.*?</script> But this doesn't seem to return any script tag that has any code within it. I.e. it from the following: <script type="text/javascript" src="Scripts/Scipt1.js"></script> <s...

Regex word boundary expressions

Say for example I have the following string "one two(three) (three) four five" and I want to replace "(three)" with "(four)" but not within words. How would I do it? Basically I want to do a regex replace and end up with the following string: "one two(three) (four) four five" I have tried the following regex but it doesn't work: @"\...

Regular Expression to match relative URLs - II

Continue with the previous question, http://stackoverflow.com/questions/3447131/regular-expression-to-match-relative-urls we are facing a slight problem with space in the relative Urls. Lets say, we have two scenarios: /abc/part%20Red/ /abc/part Red/ First relative URl is retrived but second relative URL returned /abc/part instea...

preg_replace - PHP

Afternoone guys and girls. having a bit of trouble with replacing things that are NOT 0-9A-Za-z[:space] because I cannot find a NOT metachar for preg_replace. Does anytone know if one exists and if not what is the best way to strip anything that is NOT alpha numeric or a space? Thanks in advance Alex ...