regex

Create a valid CSV with regular expressions

I have a horribly formated, tab delimited, "CSV" that I'm trying to clean up. I would like to quote all the fields; currently only some of them are. I'm trying to go through, tab by tab, and add quotes if necessary. This RegEx will give me all the tabs. \t This RegEx will give me the tabs that do not END with a ". \t(?!") How do ...

Can someone please explain this JavaScript regular expression for me?

Can someone please explain this JavaScript regular expression for me? new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ') ...

Parse a string to a specified length (without cutting words)

I have a long string that I need to parse into an array of strings that do not exceed 40 characters in length. The tricky part of this for me is making sure that the regex finds the last whitespace before 40 characters to make a clean break between strings since I don't want words cut off. ...

Wrap Text in P tag

Hi, I'm trying to figure out how to wrap text like this : Morbi nisl tortor, consectetur vitae laoreet eu, lobortis id ipsum. Integer scelerisque blandit pulvinar. Nam tempus mi eget nunc laoreet venenatis. Proin viverra, erat at accumsan tincidunt, ante mi cursus elit, non congue mauris dolor ac elit. Maecenas moll...

Regular expressions / parsing dig output / extracting text from double quotes

Hi, I need help figuring out some regular expressions. I'm running the dig command and I need to use its output. I need to parse it and get it neatly arranged as an array using php. dig outputs something like this: m0.ttw.mydomain.tel. 60 IN TXT ".tkw" "1" "20090624-183342" "Some text here1" m0.ttw.mydomain.tel. 60...

jQuery string manipulation, regex noob.

First off I don't know much about regex and need to buy a book because it's has proven to me to be difficult to pickup. Ultimately I want to take a dom element, and replace text within straight brackets "[" and "]" and insert a link around the text, and there may be multiple bracket sets in the string. function changeTip() { ...

Problem with regular expression replacement in Visual Studio 2003

I'm in the process of converting some LaTeX documentation to restructured text and having some trouble with a regular expression in Visual Studio 2003. I'm trying to convert \emph{text} to *text* using the following find/replace strings: \\emph\{([^\}]*)\} *\0* However, using this pair I get \emph{text} converted to *\emph{text}* w...

Replace multiple instances in a string in perl

I have the following use case, input present in the file as: Line1 : AA BB CC DD EE I want to replace this with 1 2 3 4 5 Output Line1: 1 2 3 4 5 In one regular expression in Perl, can I do this I was trying this but was unsucessful my @arr1 = ("AA", "BB", "CC", "DD", "EE"); open F2, $file; my $count = 0; while (<F2>) { ...

C# How to split (A:B=C)* using regex?

This is supposedly a very easy question, but I just can't seem to find the right solution. There is a string in the format: A:B=C;D:E=F;G:E=H;... whereas A, B and C are alphanumeric (and may be lower as well as upper case). A and B are of length 1+, C may be empty. I figured I'd have to use something along the lines of ((?<A>.+):(?<...

i want to capture all tags not having a specific tag

i want to capture all tags named 'STRONG' i can use <STRONG.*?</STRONG> this is working just fine but i dont want to capture these tags if the 'SPAN' tags come in these tags i want something like <STRONG.*(^(SPAN)).*?</STRONG> this is the sample text <STRONG> For technical <SPAN id=PageBreak>101</SPAN> please</STRONG> <SPAN id=PageBreak...

Inject HTML markup around certain words in a string

Say I have these two strings: "Some Text here" and "some text Here" And I have a collection that contains the words that I would like to match against the text in the strings. "Some", "Text", "Here" If one of the words match a certain word in the string (regardless if it is upper- or lower-case) I would like to take the original word f...

how to match something with regExp between roundbrackets

I have this: var regExp:RegExp = new RegExp("((.*?)%)"); and want everything between the ( and the %) the string looks like this: (-24%) I now get a return back "(-24" and have searched for a long time to find a solution but didn't find any. ...

Get numbers from string with regex

Hi, I am trying to write a regex to get the numbers from strings like these ones: javascript:ShowPage('6009',null,null,null,null,null,null,null) javascript:BlockLink('2146',null,null,null) I am having difficulty writing the regex to grab these numbers. Could anyone lend a hand? Cheers Eef ...

c# Regex.Replace

I have the following method that is replacing a "pound" sign from the file name but I want also to be able to replace the "single apostrophe ' " at the same time. How can I do it? This is the value of filename =Provider license_A'R_Ab#acus Settlements_1-11-09.xls static string removeBadCharPound(string filename) { // Replace...

Is it possible to parse this nightmare using Perl?

I'm working on some doc file, that when copied and pasted into a text file, gives me the following sample 'output': ARTA215 ADVANCED LIFE DRAWING (3 Cr) (2:2) + Studio 1 hr. This advanced study in drawing with the life .... Prerequisite: ARTA150 Lab Fee Required ARTA220 CERAMICS II (3 Cr) (2:2) + Studio 1 hr. This course afford...

RegEx in Java not working as I expected

Trying to extract strings that are wrapped in double brackets. For example [[this is one token]] that should be matched. To make things more elegant, there should be an escape sequence so that double bracketed items like \[[this escaped token\]] don't get matched. The pattern [^\\\\]([\\[]{2}.+[^\\\\][\\]]{2}) with "group 1" to extract ...

Non-greedy matching in Treetop/PEG ?

How would I do something like this in Treetop? /.+?;/ It seems like the only way is to do: [^;]+ ';' Which is kind of ugly.. any other way? .+? doesn't seem to work.. ...

Java - Reg expression using groups

From a string, I need to pull out groups that match a given pattern. An example string: <XmlLrvs>FIRST</XmlLrvs><XmlLrvs>SECOND</XmlLrvs><XmlLrvs>Third</XmlLrvs> Each group shall begin with <XmlLrvs> and end with </XmlLrvs>. Here is a snippet of my code... String patternStr = "(<XmlLrvs>.+?</XmlLrvs>)+"; // Compile and use regular e...

Shell script to extract particular content using find, xargs, and grep

Hi everyone. Well i am new to linux shell and i can't understand any regexp :( Here is my question: I have a directory called /var/visitors and under this directory, i have directories like a, b, c, d. In each of these directories, there is a file called list.xml and here is the content of list.xml belonging to /var/visitors/a directory...

How to validate a string, to only allow alphanumeric characters in it? (regex)

How to validate a string, to only allow alphanumeric characters in it? (regex) (I don't want to allow for any spaces either). ...