regex

ReSharper 5 Search with Pattern

I just recently ran into the "Search with Pattern" tool in the new ReSharper. I tried to search for private $Type$ $Var$ = new $Type$($TypeArgs$); but when I search it just says "Cannot parse pattern" when I take way the private access modifier it works. But I am trying to explicitly search for it with the access modifier. I have a...

How to remove some html tags?

I'm trying to find a regex for VBScript to remove some html tags and their content from a string. The string is, <H2>Title</H2><SPAN class=tiny>Some text here</SPAN><LI>Some list here</LI><SCRITP>Some script here</SCRITP><P>Some text here</P> Now, I'd like to EXCLUDE <SPAN class=tiny>Some text here</SPAN> and <SCRITP>Some script he...

Search and replace regular expression in Open Office calc

Hi, I've got something like this (in Open Office Calc): Streetname. Number Streetname. Number a etc. Now I want to delete everything in front of the number. So I need to do a search and replace I guess. ^.*?([0-9]) this one matches Streetname. Number .. but what should I put in the replace field? If I do the search and replace, i...

C# multiple patterns in regex.replace()

Hi, How can i pass multiple patterns to the regex.replace() pattern parameter? In PHP you just give up the array containing them. Is there some kind of same option in C#? I'm looping through some usernames and some of those usernames are surrounded by html tags. The html tags are not all the same. But i do know which ones they are. S...

Detect if a regexp is exponential

Hi, This article show that there is some regexp that is O(2^n) when backtracking. The example is (x+x+)+y. When attempt to match a string like xxxx...p it going to backtrack for a while before figure it out that it couldn't match. Is there a way to detect such regexp? thanks ...

PHP how to delete this from a string?

I want to delete this from a string: [QUOTE=*] * [/QUOTE] .* kan be anything Can anyone please provide a pattern that I can use? ...

Regex for username that allows numbers, letters and spaces

Hi, I'm looking for some regex code that I can use to check for a valid username. I would like for the username to have letters (both upper case and lower case), numbers, spaces, underscores, dashes and dots, but the username must start and end with either a letter or number. Ideally, it should also not allow for any of the special cha...

Problem extracting text out of html file using python regex

I'm working on a project that requires me to write some code to pull out some text from a html file in python. <tr> <td>Target binary file name:</td> <td class="right">Doc1.docx</td> </tr> ^Small portion of the html file that I'm interested in. #! /usr/bin/python import os import re if __name__ == '__main__': f = open('./res...

regular expression

can some tell how can i write regular expression matching abc.com.ae or abc.net.af or anything ,ae which is the last in the string is optional this is successfull with / but not . don't know why ^[a-z]{1,25}.[a-z]{3}$ answer ^[a-z]{1,30}\.[a-z]{3}((\.)[a-z]{2})?$ ...

Regex Syntax Validator

Hi. Does anybody know any tool for validating the syntax of an Regular Expression? I dont want to validate if it matches or not with some text but I want to see if there are syntax errors in the regex (missing parenthisis etc). Also, what about syntax highlighting? It would be a great help when writing complex regex. ...

Need help with Javascript Regular Expressions - Splitting text

I have a string that represents a list of tags separated by space. It may look like this: Australia 2010 David November Family If a tag contains at least one space, it must be quoted. So the string can be: "Best Friends" "My Pictures" Wow "Very Nice Photo" University Quotes are also allowed for single words. For example: "Good One...

Regular Expression - Small change needed

I need a regular expression that will allow only a to z and 0 to 9. I came across the function below on this site, but it allows a few symbols thru (#.-). How should it be done if it has to allow only a to z (both upper and lower case) and 0 to 9? I'm scared to edit it since I know nothing about regular expressions. Also is this regular...

Can I use an OR in regex without capturing what's enclosed?

I have used RegExp before but am far from an expert... I'm reading up right now for a project, but am running into an issue. I'm using rubular.com to build my regex, and their documentation describes the following: (...) Capture everything enclosed (a|b) a or b How can I use an OR expression without capturing what's in it? So if...

Matching inner pattern an unlimited amount of times within outer pattern

Say I have the following pattern: INDICATOR\s+([a-z0-9]+) which would match for example: INDICATOR AA or INDICATOR B3 I need to edit this pattern so it matches any instances of a string which starts with INDICATOR has a space and then has multiple matches of the inner pattern e.g. INDICATOR AA A3 66 B8 34 CD INDICATOR BG 4D CS INDIC...

NFA minimization without determinization

It is well-known how one gets from an NFA for a regular language to a minimal DFA. However, the DFA might have an exponentially larger number of states. What I need is a way to reduce an NFA, giving again an NFA but with a smaller number of states. T.i. I don't need the result to be deterministic, but I'd like it to be as small as possi...

preg_match() and username

function isUserID($username) { if (preg_match('/^[a-z\d_]{2,20}$/i', $username)) { return true; } else { return false; } } Easy one.., i have this, can you explain what it checks for? I know it checks if the username have length between 2-20, what more? Thanks ...

How can I get html webpage charset encode from html as string and not as dom?

Hi, How can I get html webpage charset encode from html as string and not as dom? I get html string like that: $html = file_get_contents($url); preg_match_all (string pattern, string subject, array matches, int flags) but i dont know regex, and I need to find out webpage charset (UTF-8/windows-255/etc..) Thanks, ...

Strip bad Windows filename characters

I found this function that tests whether a string is Windows filename and folder friendly: function is_valid_filename($name) { $parts=preg_split("/(\/|".preg_quote("\\").")/",$name); if (preg_match("/[a-z]:/i",$parts[0])) { unset($parts[0]); } foreach ($parts as $part) { print "part = '$part'<br>"; ...

Help with regex / ruby

Hey guys, so I'm making a script to featch words/results off of this site (http://grecni.com/texttwist.php), So I already have the http request post ready, ect. Only thing I need now is to fetch out the words, So I'm working with an html source that looks like so: <html> <head> <title>Text Twist Unscrambler</title> <META NAME="keyword...

I need help modifying a regular expression for PHP markdown

I'm modifying PHP Markdown (a PHP parser of the markup language which is used here on Stack Overflow) trying to implement points 1, 2 and 3 described by Jeff in this blog post. I've easily done the last two, but this one is proving very difficult: Removed support for intra-word emphasis like_this_example In fact, in the "normal" mark...