regex

Parsing Wiki markup in Javascript using regex

Hi folks, I'm attempting to parse some Wiki-style markup using the Javascript Creole Wiki Markup Parser as found here. I'm attempting to extend the parser to parse div tags like so: Markup: << any_content_here << HTML: <div class="left">content</div> Markup: >> any_content_here >> HTML: <div class="right">content</div> Markup: ^^ an...

What's the cross-platform regex to replace a line ending?

I've got a string like "foo\nbar", but depending on platform, that could become "foo\n\rbar", or whatever. I want to replace new lines with ", ". Is there a nice (php) regex that'll do that for me? ...

Removing html tags from a text using Regular Expression in python

I'm trying to look at a html file and remove all the tags from it so that only the text is left but I'm having a problem with my regex. This is what I have so far. import urllib.request, re def test(url): html = str(urllib.request.urlopen(url).read()) print(re.findall('<[\w\/\.\w]*>',html)) The html is a simple page with a few links a...

Need a regular expression to get rid of parenthesis in html image tag filename

So say I have some html with an image tag like this: <p> (1) some image is below: <img src="/somwhere/filename_(1).jpg"> </p> I want a regex that will just get rid of the parenthesis in the filename so my html will look like this: <p> (1) some image is below: <img src="/somwhere/filename_1.jpg"> </p> Does anyone know how to do this...

Regex to match all characters except letters and numbers

I want to clean the filenames of all uploaded files. I want to remove all characters except periods, letters and numbers. I'm not good with regex so I thought I would ask here. Can someone point me to a helpful site or show me how to put this together? I'm using PHP. ...

Replace all (.) other then first occurence in PHP

Example Input = 1.1.0.1 Expected output = 1.101 ...

How to handle the different dialects of regular expressions (java vs. xsd)?

When I try to validate an XML file against an XSD in java (see this example) there are some incompatibilities between the regular expressions given in the XSD file and the regular expressions in java. If there is an regular expression like "[ab-]" in the XSD (meaning any of the characters "a", "b" or "-", java complains about a syntax e...

emailid validation in vb.net

how to validate this id in vb.det "[email protected]" using=ValidationExpression="^[\w-]+@[\w-]+.(com|net|org|edu|mil)$ this above code will not accept this id but this is a valid one for example <tr> <td align="right"> <font face="Arial" size="2">Email Address:</font> </td> <td> <asp:Text...

Help to make a good Regex????

Hello, Can anyone help me make a regex or give me a good solution that can split/check the following string: "<2342Flsdn3Z><9124Fsflj20>" Everything starts with a "<" and the 6 caracter is a "F" and the string ends with a ">" Is it possible to make a Regex that can find "strings" like this? ...

Regular expression to remove <p> tags around elements wrapped in [...]'s

Hey all, I'm a total regexp noob. I'm working with wordpress and I'm desperately trying to deal with wordpress's wautop, which I hate and love (more hate!). Anyways I'm trying to remove <p> tags around certain commands. Here's what I get: <p> [hide] <img.../> [/hide] </p> or <p> [imagelist] <img .../> <img .../> [/imagelist] </p> ...

Matcher returns matches on a regex pattern, but split() fails to find a match on the same regex?

I can't see a reason why the Matcher would return a match on the pattern, but split will return a zero length array on the same regex pattern. It should return something -- in this example I'm looking for a return of 2 separate strings containing "param/value". public class MyClass { protected Pattern regEx = "(([a-z])+/{1}([a-z0-9...

Using Python Reg Exp to read data from file

I'm having trouble using python reg exp to read data from a file. The file has data I want and some info I'm not interested in. An example of the info I'm interested in is below. The number of rows will vary FREQ VM(VOUT) 1.000E+00 4.760E+01 1.002E+00 4.749E+01 Y I want to create a list of tuples like: [(1.000, 47.6),(...

split method of String class does not include trailing empty strings

The split method of String class does not include trailing empty strings in the array it returns. How do I get past this restriction: class TestRegex{ public static void main(String...args){ String s = "a:b:c:"; String [] pieces = s.split(":"); System.out.println(pieces.length); // prints 3...I want 4. } } ...

Time comparevalidator

Hi, I want to validate Time-Start and Time-End. The time format is like this 2:15:00 AM I want to make sure that the Time-End must be greater or equal to the Time-Start. The Time-Start gets the time from DropDownListHourStart(1-12) and DropDownListMinuteStart(1-59) and DropDownListSecondStart(00) and DropDownListAMPMStart(AM-PM) The T...

Qt Regex matches HTML Tag InnerText

I have a html file with one <pre>...</pre> tag. What regex is necessary to match all content within the pre's? QString pattern = "<pre>(.*)</pre>"; QRegExp rx(pattern); rx.setCaseSensitivity(cs); int pos = 0; QStringList list; while ((pos = rx.indexIn(clipBoardData, pos)) != -1) { list << rx.cap(1); pos += rx.matchedLength(); } l...

Help constructing regex

Hi, I need to know if a string matches a number of different criterias. I'm trying to solve this by using a regular expression and then see if it matches (in Java: str.matches(myRegex);), but I can't get it right. The criterias are as follows: The string to match is constructed of 4 letters, [A-Z] It may be preceeded (but not necessa...

Python regex for matching bb code

Hi to all, I'm writing a very simple bbcode parse. If i want to replace hello i'm a [b]bold[/b] text, i have success with replacing this regex r'\[b\](.*)\[\/b\]' with this <strong>\g<1></strong> to get hello, i'm a <strong>bold</strong> text. If I have two or more tags of the same type, it fails. eg: i'm [b]bold[/b] and i'm [b]b...

Bug in my preg-match

Hai all i have a big problem right now i have this sample code: preg_match_all("/\[BLOG\=\[(.*)]](.*)\[\/BLOG]/U", $this->soruces , $match_list ); and i don't know why its not will working, its print this out to me Array ( [0] => GROUPID=23|CATID=28|SORT=ASE [1] => GROUPID=23|CATID=29|SORT=ASE [2] => GROUPID=23|CATID=30|SORT=ASE ) ...

Regular Expressions and Assembly

I know 8086 Assembly and learning MIPS Assembly. Also, I'm learning Regular Expressions, then I want to know: How can I use Regular Expressions on them? ...

Extracting URLs using regex in .NET

I've taken inspiration from the example show in the following URL csharp-online and intended to retrieve all the URLs from this page alexa using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Text.RegularExpressions; namespace ExtractingUrls { ...