regex

jquery validation with regular expression

I want to validate a field which will allow only "xxxx"[not " " or "xxxx"" or somthing else] with regular expression in Jquery validator ,so what the regular expression would be...plzz suggest. ...

Regular expression to remove <br> from <pre>

I am trying to remove the <br /> tags that appear in between the <pre></pre> tags. My string looks like string str = "Test<br/><pre><br/>Test<br/></pre><br/>Test<br/>---<br/>Test<br/><pre><br/>Test<br/></pre><br/>Test" string temp = "`##`"; while (Regex.IsMatch(result, @"\<pre\>(.*?)\<br\>(.*?)\</pre\>", RegexOptions.IgnoreCase)) { ...

Parse HTML-like metalanguage with Regular Expressions (Python)

Hi! I want to parse html tags manually with Regular Expressions. I see next problems: sting with tags: <h1 title="<this not a tag>">...</h1> - how to parse correct this tag, if in string parameter appear tags? tag can be incorrect like this: <h1 title="not closed string> or this <h1 title=not opened string"> - this tag also should be...

Java Regular expression

I have a string and a pattern that i want to search for in that string. Now, when i match the pattern in the string, i want to know the string that matches my pattern. String template = "<P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT></P>"; String pattern = "<FONT.*>"; Pattern.compile(pattern,Pattern.CASE_...

How to get all pieces from regular expression (Python)

Hello! I want get all mathes from this expression: import re def my_handler(matches): return str(matches.groups()) text = "<a href='#' title='Title here'>" print re.sub("<[a-zA-Z]+( [a-zA-Z]+=[\#a-zA-Z0-9_.'\" ]+)*>", my_handler, text) Actual result: (" title='Title here'",) Expected result: ("a", " href='#'", " title=...

Regex Rules for First and Second Character

Hello, I need help on following regular expression rules of javascript and php. JS var charFilter = new RegExp("^[A|B].+[^0123456789]$"); PHP if (!preg_match('/^[A|B].+[^0123456789]$/', $data_array['sample_textfield'])) { This regular expression is about First character must be start with A or B and last character must not inclu...

Browsers different interpretations of a regex with lookahead

I am running a split in javascript with /\s+(AND|OR)(?=\s+")\s+/ on "email" IS NOT NULL AND "email" LIKE '%gmail.com' OR "email" = '[email protected]' Now, my understanding of regular expressions would lead me to expect obtaining the following array: [0]: "email" IS NOT NULL [1]: "email" LIKE '%gmail.com' [2]: "email" = '[email protected]' ...

^([0-9])+$ RegEx supports numbers and spaces, but how to support empty lines too?

The RegEx ^([0-9])+$ supports numbers and spaces. However, I want it to support empty lines too. How? ...

Mysql replace regular expression

Hi is there any way to 'replace' all occurences of 10 or more occurances of _ (underscore) within a mysql table with something else. background I've inherited a database of content written for the web. Unfortunately the origional author has used ________________ instead of <hr /> for the horizontal rules. It's a wordpress installation...

Is there a lib to generate data according to a regexp? (Python or other)

Given a regexp, I would like to generate random data x number of time to test something. e.g. >>> print generate_date('\d{2,3}') 13 >>> print generate_date('\d{2,3}') 422 Of course the objective is to do something a bit more complicated than that such as phone numbers and email addresses. Does something like this exists? If it does,...

Help with a regex

I have a regex that works: ABC-[0-9]+ I also have a regex: DEF-[0-9]+ But I don't get how to combine the two so it will match them both I tried ABC-[0-9]+ | DEF-[0-9]+ but it didn't really work... This is all in Java regex if it matters. Any help's appreciated! ...

Regex to Find/replace argument pattern in a function-call across all files

I have a large codebase, where we need to make a pattern-change in the argument of a specific function. i.e. All arguments to a function foo() are renamed from the format something.anotherThing are to be renamed as something_anotherThing The arguments can be anything but will always be in a str1.str2 format. It is to be done for argume...

How optimize this regex?

My tool gets a plain text and gradually generates the "tags" by replacing a terms from text in tags. Due to existence of some compound terms, the only way (i think) is use ReplaceAll regex. Thanks to the friends of stackoverflow, in my last question i got a excellent regex to my app, but after a tests, emerged a new need: "A regex ...

Why is my regex removing spaces?

$str = "&amp; &svnips &nbsp; &Acirc; &there4; &asymp; osidnviosd & sopinsdo"; $regex = "/&[^\w;]/"; echo preg_replace($regex, "&amp;", $str); I'm trying to replace all un-encoded ampersands with encoded ones. The problem is it's removing the space between & and sopinsdo. Any idea why? ...

htaccess redirect to a folder...

I wasn't sure what the title should be but its s simple concept but I'm useless with .htaccess rewrites. I currently have: RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1 which will happily send all requests to my index and I can do what I want. I have: RewriteRule ^events/([a-zA-Z0-9-./]+)/?$ index.php?page=events/index&id=$1 ...

Using a Single-String Regex While Doing In-Place Perl Editing

I'm using one-off perl -pi -e commands to do simple search and replace from within a bash script. Most of my regexes work fine, until I get to these: perl -pi -e 's#\<\?mso-application.*\<Table.*Rows="1"\>#\<Table\>#s' 1.xml perl -pi -e 's#\</Table.*#\</Table\>#s' 1.xml Please don't mind the # marks instead of slashes, I didn't want t...

Safety precautions while doing html form processing using javascript, PHP, MySQL

I am not a professional web developer but I love web development as a hobby.. I am a student and I was asked to make a departmental event web site. I need to create HTML forms for user registration. I am aware of XSS Scripting attack and SQL Injection. But don't know how they exactly work. I am using PHP and MySQL on server side. I am t...

Problem with quantifiers and look-behind

### Ruby 1.8.7 ### require 'rubygems' require 'oniguruma' # for look-behind Oniguruma::ORegexp.new('h(?=\w*)') # => /h(?=\w*)/ Oniguruma::ORegexp.new('(?<=\w*)o') # => ArgumentError: Oniguruma Error: invalid pattern in look-behind Oniguruma::ORegexp.new('(?<=\w)o') # => /(?<=\w)o/ ### Ruby 1.9.2 rc-2 ### "hello".match(/h(?=\w*)/) ...

Regex - Match any sequence of characters except a particular word in a URL

I want to match a URL that contains any sequence of valid URL characters but not a particular word. The URL in question http://gateway.ovid.com and I want to match anything but the word 'gateway' so: http://abc123.ovid.com - would match http://abc.123.ovid.com - would match http://abc-123.ovid.com - would match http://fdfsffdfs.ovid.co...

Pattern match a string in Lua

I have the following string to split into a table using lua: (the data is aligned with each other. I did not find out how to write format it like that on this site) IP: 192.168.128.12 MAC: AF:3G:9F:c9:32:2E Expires: Fri Aug 13 20:04:53 2010 Time Left: 11040 seconds the result should be put into a table l...