regex

Regular expression to replace text before </script> tag or between text in script tag in c#

In my html content, i want to replace all "bold" text with "italic" existing in between script tag using c#. I have two option here for applying regular expression a) replace all between script tag b) replace all before the ending of script tag So what will be the regular expression using any method? ...

Regex anchor question

Would an anchor like "^" or "\A" at the beginning of this regex make any sense - any difference? $string =~/(.*)([a-z])$/ ...

REGEX to find and replace IMG elements

Possible Duplicate: I'm looking for a regular expression to remove a given (x)HTML tag from a string I have a long HTML file and I need to remove all the <img /> tags inside it and all the <a><img /></a> anchors. What I'm thinking of is writing a PHP script that does the job. But each image and link has different number attri...

Java replaceAll() & split() irregularities

I know, I know, now I have two problems 'n all that, but regex here means I don't have to write two complicated loops. Instead, I have a regex that only I understand, and I'll be employed for yonks. I have a string, say stack.overflow.questions[0].answer[1].postDate, and I need to get the [0] and the [1], preferably in an array. "Easy...

Regular expression for checking if capital letters are found consecutively in a string?

Hi, I want to know the regexp for the following case: The string should contain only alphabetic letters. It must start with a capital letter followed by small letter. Then it can be small letters or capital letters. ^[A-Z][a-z][A-Za-z]*$ But the string must also not contain an consecutive capital letters. How do I add that logic to ...

Regex for netbios names

I got this issue figuring out how to build a regexp for verifying a netbios name. According to the ms standard these characters are illegal \/:*?"<>| So, thats what I'm trying to detect. My regex is looking like this ^[\\\/:\*\?"\<\>\|]$ But, that wont work. Can anyone point me in the right direction? (not regexlib.com please...) A...

PHP Regex: How to get capital words then add string if a ucwords matches?

Hi, I have this dynamic string "ZAN ROAD HOG HEADWRAPS The most popular ZAN headwrap style-features custom and original artwork" EDIT How can I check all the capital words then if I encountered a ucwords() or title case word then I will automatically add a '--' after the last capital word? Note: The capital words are the produ...

Perl: find if a variable's value matches that in an array

I'm a perl newbie. I have a code in which a variable is loaded with several values during a foreach loop. What I want to do is to perform some operation on that variable only if its in that array. What is the most efficient way to do this in perl as the data I am working on is very large. A simple example of my question is, say I have a...

Regular expression - any text to URL friendly one

PHP regular expression script to remove anything that is not a alphabetical letter or number 0 to 9 and replace space to a hyphen - change to lowercase make sure there is only one hyphen - between words no -- or --- etc. For example: Example: The quick brown fox jumped Result: the-quick-brown-fox-jumped Example: The quick brown fox ju...

How do you "debug" a regular expression with sed?

I'm trying to use a regexp using sed. I've tested my regex with kiki, a gnome application to test regexpd, and it works in kiki. date: 2010-10-29 14:46:33 -0200; author: 00000000000; state: Exp; lines: +5 -2; commitid: bvEcb00aPyqal6Uu; I want to replace author: 00000000000; with nothing. So, I created the regexp, that works when ...

replacing strings which does not match the pattern in JavaScript regex

Possible Duplicate: splitting a string in js where a pattern DOES NOT match? i want to replace the lines with "!REPLACED!" from the text similar to this but those which does not match URL pattern or in simple words, which does not begin with http:// or httpS:// Some Good Tutorials http:// a.com/page1 http:// a.com/page2 Some ...

PHP multiple new lines

I'm a little stuck. How do I remove multiple newlines which are in a row with one newline. There could be anything up to 20 newlines next to each other. For example James said hello\n\n\n\n Test\n Test two\n\n Would end up as: James said hello\n Test\n Test two\n ...

How to extract the email id from textarea field.

Hi, I am using cakephp. And I have textarea field where users paste data, I using tinymce plugin to format text. I have warned users not to enter telephone number or email address inside the textarea. But, I dont want to take chances. Is there a way I can extract the telephone number and email from textarea and replace it something li...

using the sed command: match between 2 regular expressions

The syntax for this is: sed -n '/Regex1/,/Regex2/p' But this includes the lines where Regex1 and Regex2 are found, how can I exclude them? For example: abcd-Regex1 BlaBlaBla abcd-Regex2 Then I only want: BlaBlaBla ...

Strip brackets and the word "The" from a string

I have been trying to figure out regex myself and to no avail can I get the last bracket to disappear from a string. For example: [The Day the Earth Stood Still] I can only get: Day the Earth Stood Still] with the following RegEx code: /(\[|\](^The ))\2/ I'm aiming for just: Day the Earth Stood Still Any help would be greatly a...

Prepare string with regex for HTML tags management

P/S: I am a PHP programmer. Given: div{3|5|6|9}[id = abc| class=image], a[id=link|class=out] I want to use regex to generate a result as an array, e.g: array( [div] => array( "3|5|6|9", "id = abc| class=image" ) [a] => array( "", "id=link|class=out"...

How to use Python re module to replace \n with nothing in a single file

Regards to all. I'm developing a Image compression system using Python Image Library. The basic workflow is: Read all images of a certain directory with : find /opt/images -name *.jpg > /opt/rs/images.txt Read this file and storage the result in a Python list Iterate the list, create a Image object and passing like a argument to the co...

How do I search and replace using regex in MySQL?

I'm trying to update a field which contains HTML and I want to find all the rows that have forms in them and remove the form tags and anything in between them, however I'm running into problems with my select and the regex. SELECT * FROM db.table WHERE body REGEXP "<form[^>].+?>.+?</form>"; and the error I get says: 'repetition-operat...

Does anyone see why the first part of my regex isn't working in Python?

I tested this regex out in RegexBuddy ,[A-Z\s]+?,(LA|RO|MU|FE|AV|CA),(ML|FE|MN|FS|UN)?,(\d+/\d+/\d{4})? and it seems to be able to do what I need it to do - capture a piece of data that looks like one of the following: ,POWDER,RO,ML,8/19/2002 ,POWDER,RO,,, ,POWDER,RO,,8/19/2002 ,POWDER,RO,ML,, When I use it in a python string: r",...

Boost wregex throwing exception, regex syntax wrong?

Hi, I have imported Boost library in to a .dll that I am using. I am trying to parse a string using: boost::wregex regPlayerAtSeat(L"*Governor: Seat.?[1-9].*"); But all I get is an 'interop service exception. Is the syntax of my regex wrong? Thanks, R. ...