regex

Regex to extract this semi formatted data

Alright, I can't quite figure out how to do this. Given the following text: Roland AX-1: /start Roland's AX-1 strap-on remote MIDI controller has a very impressive 45-note velocity sensitive keyboard, and has switchable velocity curves, goes octave up/down, transpose, split/layering zones, and has fun tempo control for sequencers and...

Isolate SQL field using regex

I'm trying to isolate a specific field in a SQL dump file so I can edit it but I'm not having any luck. The regex I'm using is: ^(?:(?:'[^\r\n']*'|[^,\r\n]*),){6}('[^\r\n']*'|[^,\r\n]*) Which is supposed to grab the seventh field and place it inside reference 1. The trouble is that this is stumbling when ever it finds a comma inside...

.NET Regular Expression for N number of Consecutive Characters

I need a regular expression that matches three consecutive characters (any alphanumeric character) in a string. Where 2a82a9e4eee646448db00e3fccabd8c7 "eee" would be a match. Where 2a82a9e4efe64644448db00e3fccabd8c7 "444" would be a match. etc. ...

WordPress: Problem with the shortcode regex

This is the regular expression used for "shortcodes" in WordPress (one for the whole tag, other for the attributes). return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; It ...

Using regex to fix phone numbers in a CSV with PHP

My new phone does not recognize a phone number unless its area code matches the incoming call. Since I live in Idaho where an area code is not needed for in-state calls, many of my contacts were saved without an area code. Since I have thousands of contacts stored in my phone, it would not be practical to manually update them. I decid...

How can I extract URLs from plain text with Perl?

I need the Perl regex to parse plain text input and convert all links to valid HTML HREF links. I've tried 10 different versions I found on the web but none of them seen to work correctly. I also tested other solutions posted on StackOverflow, none of which seem to work. The correct solution should be able to find any URL in the plain te...

Regex Replace Between " Encoding

I want to be able to replace style="STUFF" I keep thinking that this is the correct REGEX: style=(")(?!")*(") But for some reason that won't match. Any ideas? ...

Need to replace everything after the second match

Ok so if I have this pattern: ab&bc&cd&de&ef And I need to replace all the ampersands except for the first one with commas so it ends up looking like this: ab&bc,cd,de,ef Its probably very simple but for the life of me I can't get this one figured out... ...

Using regexp to search for the string matching multiple words arranged in random.

How can I write the regexp to match multiple words in random order? For example, let's assume the following lines: Dave Imma Car Pom Dive Dive Dome Dare Imma Car Ryan Pyro Dave Imma Dive Lunar Happy Dave I want to search the string for the one matching "Dave" "Imma" and "Dive", expecting the 1st and 4th line. Is this possible? ...

Regular Expression to split "/n"

I want to split the /n from my string in Java. For example, I have one String field which has 2 lines space ( /n). I have to find out lines ( wherever mopre than one lines is coming) and should replace with one line spaces. "This is Test Message thanks Zubair " From the above example, there are more spaces between "This is Te...

regex. How can I match the value between '+' and ':' ?

I have this string: sometext +[value]:- I would like to match the value(1-3 numerical characters) (with regex, javascript) sometext may contain a +sign if i'm unlucky so I don't wanna end up with matching some +text +value:- I sat up last night banging my head against this, so I would be really glad if someone could help me. ...

Problem with Javascript RegExp-mask

I have a string that looks something like this: {theField} > YEAR (today, -3) || {theField} < YEAR (today, +3) I want it to be replaced into: {theField} > " + YEAR (today, -3) + " || {theField} < " + YEAR (today, +3) + " I have tried this: String.replace(/(.*)(YEAR|MONTH|WEEK|DAY+)(.*[)]+)/g, "$1 \" + $2 $3 + \"") But that giv...

Regular expression: who's greedier?

My primary concern is with the Java flavor, but I'd also appreciate information regarding others. Let's say you have a subpattern like this: (.*)(.*) Not very useful as is, but let's say these two capture groups (say, \1 and \2) are part of a bigger pattern that matches with backreferences to these groups, etc. So both are greedy, i...

Regular Expression library/set to parse sql

Anyone know of any re libraries out there to help parse columns, functions, and values from an SQL WHERE clause? Example strings: COLUMN=='VALUE' COLUMN=='VALUE' AND COLUMN2='VALUE' FUNCTION(COLUMN)==FUNCTION('VALUE') I'm working in Python, but can port most anything over... ...

How to regex match text with different endings?

This is what I have at the moment. <h2>Information</h2>\n +<p>(.*)<br />|</p> ^ that is a tab space, didn't know if there was a better way to represent one or more (it seems to work) Im trying to match the 'bla bla.' text, but my current regex doesn't quite work, it will match most of the line, but I want it to mat...

codingbat wordEnds using regex

I'm trying to solve wordEnds from codingbat.com using regex. Given a string and a non-empty word string, return a string made of each char just before and just after every appearance of the word in the string. Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words. w...

301 htaccess redirect: add segment to old URL's

I'm trying to make sure old url's aren't broken after the site's URL structure has changed from this: http://www.domain.com/section/entry_name to this: http://www.domain.com/section/event_name/entry_name But to make it a bit more complex, I'm using the segments to sort entries, for example: http://www.domain.com/news/amazing_ev...

String replace diacritics in C#

I'd like to use this method to create user-friendly URL. Because my site is in Croatian, there are characters that I wouldn't like to strip but replace them with another. Fore example, this string: ŠĐĆŽ šđčćž needs to be: sdccz-sdccz So, I would like to make two arrays, one that will contain characters that are to be replaced and other ...

Replacing multiple `-` with one `-` without regexp

I've seen so many misuses of RegExp, I don't really like it :) I have string (as a result of two str_replaces) that might look something like this: .?This iš my ".stRiNg."! | V --this-is-my---string--- Is there any way better than $string = trim(preg_replace('/[-]+/u','-', $string),'-'); to get: this-is-my-st...

Regular Expression, JEditorPane, Self-closing tags

I'm am using JEditorPane to render basic HTML. But it renders self-closing tags incorrectly, specifically br tags, e.g. <br /> is bad but <br> is good. I would like to use String.replaceAll(regex, "<br>") to fix the HTML, where regex is a regular expression matching any self-closing br tag with case-insensitivity and zero to infinity n...