regex

How to replace double/more letters to a single letter?

Hi I need to convert any letter that occur twice or more within a word with a single letter of itself. For example: School -> Schol Google -> Gogle Gooooogle -> Gogle VooDoo -> Vodo I tried the following, but stuck at the second parameter in eregi_replace. $word = 'Goooogle'; $word2 = eregi_replace("([a-z]{2,})", "?", $word); If ...

Regular expression to get all the value between custom TAG

I have custom tag for FLASH object, which i want to include in cms content. now when i read the content, i would like to grab those custom tag and the value in between. Custom TAG: <myflash filename="test.swf" width="500" height="400"> <param name="wmode" value="somevalue"></param> <param name="bgcolor" value="#ffffff"></param> <...

.NET RegExp engine search performance optimization

Hello, I have List collection with around 35,000 strings Typical string looks like this: "<i>füüs</i>ampri tähis;lüh ld-st<i>anno</i>, aastal;<i>maj</i> lüh pr-st<i>argent</i>, raha (kursisedelitel)" Basically this string contains bunch of words in Estonian :) I need to allow user to perform RegExp search on 35,000 strings If I pe...

.NET: Find hex strings with regular expressions

I need help with regular expression. I have very large collection of text files with different contents. But every file contains one hexadecimal key. Every key has exactly 16 hexadecimal digits ("E4 34 F1 FB...") and always begins with "00" or "01". In some cases they have one separator character (":"). Here are some example keys: 00...

Pb .NET/C# : Regex.Match() never ends

Hi All, Let's consider the two following lines in C# (using framework .NET 3.5) Regex regex = new Regex(@"^((E|e)t )?(M|m)oi (?<NewName>[A-Za-z]\.?\w*((\-|\s)?[A-Za-z]?\w{1,})+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); Match m = regex.Match("moi aussi jaimerai etre un ordinateur pour pas m'énnerver "); (sorry it's a frenc...

Unable to understand a line in SED

I run the following code sed 's/\([^ ]+\) your \([^ ]+\)/ \2\1er/' < fail The file fail is fail your test The above command gives me fail your test although it should give "testfailer". The second and first globs \2\1 should be at the start of the word "er". This suggests me that the problem may be in the regexes in the searc...

Why do on-line parsers seem to stop at regexps?

I've been wondering for long why there doesn't seem to be any parsers for, say, BNF, that behave like regexps in various libraries. Sure, there's things like ANTLR, Yacc and many others that generate code which, in turn, can parse a CFG, but there doesn't seem to be a library that can do that without the intermediate step. I'm interest...

Dynamically Built Regular Expressions are running extremely slow!

I'm generating regular expressions dynamically by running through some xml structure and building up the statement as I shoot through its node types. I'm using this regular expression as part of a Layout type that I defined. I then parse through a text file that has an Id in the beginning of each line. This id points me to a specific lay...

how to select inner matches in lex

Hello, am new to lex and I wanna take all the matches specific to a regular expression for example in the following text : /* text text text text text */ text text /* text text text text text text text text */ i wanna choose the two matches between /* and */ but lex matches the whole outer match and doen't return the two! I u...

How do I return only the matching regex when i select-string(grep) in powershell

Hello, I trying to find a pattern in files, but i when i get a match using select-string, i don't want the entire line, i just want the part that matched. Is there a parameter i can specify to do this? Ex: If i did select-string .-.-. and the file contained a line with: abc 1-2-3 abc I'd like to get a result of just "1-2-3" inst...

How do I use JavaScript for number formatting?

Hi, I want to use JavaScript to restrict input on a text box to currency number formatting. For example: <input type="text" value="2,500.00" name="rate" /> As given above, the text box should accept only numbers, commas and a period. But, after the period it should accept two digits after numbers. How do I accomplish this? Please ...

preg_replace() help in PHP

Hi Consider this string hello awesome <a href="" rel="external" title="so awesome is cool"> stuff stuff What regex could I use to match any occurence of awesome which doesn't appear within the title attribute of the anchor? So far, this is what I've came up with (it doesn't work sadly) /[^."]*(awesome)[^."]*/i Edit I took Alan M...

c# regex to find and replace reusing part of the matched text

Hi, I need to do a search and replace on long text strings. I want to find all instances of broken links that look like this: <a href="http://any.url.here/%7BlocalLink:1369%7D%7C%7CThank%20you%20for%20registering"&gt;broken link</a> and fix it so that it looks like this: <a href="/{localLink:1369}" title="Thank you for registering">...

How to count URL domains in MySQL?

I have a MySQL table with a column of well-formed URLs. I'd like to get a table of the unique domain names in the column, and the number of times each domain appears. Is there a MySQL query that can do this? I thought of doing something like... SELECT COUNT(*) FROM log GROUP BY url REGEXP "/* regexp here */" ...but this doesn't work ...

Jmeter - Regex issue with embedded variable and $

Greetings, In Jmeter's regex component, I am running into an issue when the expression has both a variable AND a literal '$'. It always returns as fail. When I replace the variable with a hardcoded value, it works fine. I have verified the variable is returning the expected value in previous call. Failed Expression: (variable and lit...

appending text to matching element attributes within a class in jQuery

I'm trying to append query parameters to links within blocks of text within a class, such as <div class="container"> consectetur <a href="foo.php?q=bar">adipisicing</a> </div> where the ?q=bar is appended. Here's my function: function appendRef(container,reftag) { var Link = $(container).attr("href"); var afterLink = reftag; $(...

Find all IPs on an HTML Page

I want to get an HTML page with python and then print out all the IPs from it. I will define an IP as the following: x.x.x.x:y Where: x = a number between 0 and 256. y = a number with < 7 digits. Thanks. ...

How do I extract data from a web page with regexes?

I am writing a curl script for collecting information about some sex offenders, i have developed the script that is picking up links like given below: http://criminaljustice.state.ny.us/cgi/internet/nsor/... (snipped URL) Now when we go on this link I want to get information under all the fields on this page like Offender Id:, last nam...

Writing a syntax highlighter

I was hoping to write my own syntax highlighter for a summer project I am thinking of working on but I am not sure how to write my own syntax highlighter. I know that there are bunch of implementations out there but I would like to learn about regular expressions and how syntax highlighting works. How does syntax highlighting work and ...

how to extract formating part from a string

How does one extract only the formatting part from a string. For example: if I have a string = "Warning: the error {0} has occurred. {1, 9} module has {2:0%} done." I would like to extract {0}, {1,9} and {2:0%} out into a sting array. Is there a regular expression or something that can be done other than my way of looping the string wit...