regex

RegExp problem

Hi. I have a problem creating regular expression for the following task: Suppose we have HTML-like text of the kind: <x>...<y>a</y>...<y>b</y>...</x> I want to get a collection of values inside "y" tags located inside given "x" tag, so the result of the above example would be a collection of two elements ["a","b"]. additionaly we k...

RegExp in XSLT

Hi all! I need to parse Visual Studio automatically generated XML documentation to create a report. I decided to use XSLT but I'm very new to it and need help. Common template is: <doc> <members> <member name="F:MyNamespace"> <summary>Some text</summary> </member> </members> </doc> I want to isolate members with nam...

How to include ' ' and ',' in regular expression \w?

How can I include a blank space ' ' and a comma ',' in this simple regular expression? \w{1,64} \w corresponds to: [A-Za-z0-9_], viz avery char between a-z (case sensitive/insensitive), numbers between 0-9 and the underscore. I need to add space and comma to this. I've been trying directly whit [A-Za-z0-9_, ] but this did allow cha...

End user tool for generating a regular expression

We have a SaaS application requirement to allow a user responsible for building a CMS site to define up to 10 custom fields in a form. As part of this field definition we want to add a field validation option which we will store (and apply at runtime) as a reg-ex. Are there any tools, code samples or similar that offer a wizard style f...

Regular expression : Match anything but full token

I have the following snippet where I would like to extract code between the {foreach} and {/foreach} using a regular expression: {foreach (...)} Some random HTML content <div class="">aklakdls</div> and some {$/r/template} markup inside. {/foreach} I already have: {foreach [^}]*} but I am unable to match anything after that. Is the...

Recognize URL in plain text

This should be easy, but I'm not sure how to best go about it. I have a WinForms app that lets the user type in long descriptions. Occaisionally, they would type in URLs, and the RichTextBox would recognize them and make them clickable when displayed. I'm moving the app to the web, and I'm not sure how to make those same URLs clickable....

Shorten URL value as Javascript variable

I'm using the jQuery Treeview plugin for navigation on a site with nested levels of categories. In each category there are then products, each of which have one or more information types. So my URLs can be either: foo.com/view/cat_id/ foo.com/view/cat_id/prod_id/ foo.com/view/cat_id/prod_id/info_id/ Trouble is, the navigation for th...

Double Spacing Complex Sed Output

Let me start off by saying that I know there is probably a much simpler way to do this. But this is what i have and yes hopefully I can make some improvements and/or simplifications at the end. Goal as of this moment To double space the output stored in the $tmp variable below and individually number each line. Doing this should give m...

regexp for finding everything between <a> and </a> tags

Hi, I'm trying to find a way to make a list of everything between <a> and </a> tags. So I have a list of links and I want to get the names of the links (not where the links go, but what they're called on the page). Would be really helpful to me. Currently I have this: $lines = preg_split("/\r?\n|\r/", $content); // content is the giv...

Selecting rows where first n-chars are equal (MySQL)

I have a table with playerhandles, like this: 1 - [N] Laka 2 - [N] James 3 - nor | Brian 4 - nor | John 5 - Player 2 6 - Spectator 7 - [N] Joe From there I wanna select all players where the first n-chars match, but I don't know the pattern, only that it's the first n-chars. In the above example I wan't it to return rows 1,2,3,4 and 7...

Why is $1 empty in my substitution?

I am trying to put the stuff within parentheses into the value of a src attribute in an img tag: while(<TOCFILE>) { $toc_line = $_; $toc_line =~ s/<inlineFig.*?(\.\.\/pics\/ch09_inline99_*?\.jpg)*?<\/inlineFig>/<img src="${1}" alt="" \/\>/g; $new_toc_file .= $toc_line; } So I expected to see tags like this in the output: ...

$1 outputting no characters in regex

A couple people just recommended removing the curly brackets from ${1}, but that didn't seem to change anything; still getting nothing for $1. I am trying to put the stuff within parentheses into the value of a src attribute in an img tag: $toc_line =~ s!<inlineFig.*?(\.\./pics/ch09_inline99_*?\.jpg)*?</inlineFig>!<img src="$1" alt="" ...

Regular expression matching in jQuery

In jQuery, is there a function/plugin which I can use to match a given regular expression in a string? For example, in an email input box, I get an email address, and want to see if it is in the correct format. What jQuery function should I use to see if my validating regular expression matches the input? I've googled for a solution, b...

Python regex

I have a string like this that I need to parse into a 2D array: str = "'813702104[813702106]','813702141[813702143]','813702172[813702174]'" the array equiv would be: arr[0][0] = 813702104 arr[0][1] = 813702106 arr[1][0] = 813702141 arr[1][1] = 813702143 #... etc ... I'm trying to do this by REGEX. The string above is buried in an...

How can one turn regular quotes (i.e. ', ") into LaTeX/TeX quotes (i.e. `', ``'')

Given a document written with normal quotes, e.g. Ben said "buttons, dear sir". I replied "Did you say 'buttons'?" to him. What ways can one turn these sort of things into LaTeX quotes, with the appropriate semantics. i.e. Ben said ``buttons, dear sir''. I replied ``Did you say `buttons'?'' to him. So that LaTeX produces: Ben said...

What does the Perl substitution operator act on?

I have been programming in Perl, off and on, for years now, although only sporadically is it my primary language. Because I often go months without writing any perl, I rely heavily on my dog-eared Camel Book to remind me how to do things. However, when I copy recipes verbatim with no understanding, this bothers me. This is one of the mos...

Regular Expression, numbers?!

Hi guys, I made a code that translate strings to match each word from the array 0ne to the array two and its showing the right results. But how to let the compiler take the number in the string and print it out as it is, ummmm see the code i wrote class Program { public static string[] E = { "i", "go", "school", "to", "at"...

Regular expression to match code blocks multiple times

I want to match a block of code multiple times in a file but can't work out the regular expression to do this. An example of the code block is: //@debug ... // code in here ... //@end-debug (possibly more comments here on same line) Each code block I'm trying to match will start with //@debug and stop at the end of the line containing...

How can I find a substring within a string using Perl?

I have a string from which I wish to extract a single word, but with a numerical appended to it, which might be different in each line: This is string1 this is string This is string11 This is string6 and it is in this line I want to parse this file and get the the values of "stringXXX", starting from 0 to 100 # suppose ABC.txt conta...

How do I match a square bracket literal using RegEx?

What's the regex to match a square bracket? I'm using \] in a pattern in eregi_replace, but it doesn't seem to be able to find a ]... ...