regex

jQuery regex, remote with validation

I have this: <script type="text/javascript"> jQuery().ready(function() { // validate signup form on keyup and submit jQuery("#regform").validate({ rules: { NickName: { required: true, minlength: 2, remote : "user_availability.php", }, }...

Gracefully handling HTML tags on form submission in asp.net MVC 2

Hi I have a MVC site and will have users inputting text to be displayed on a web page. I am trying to come up with a graceful way of handling any HTML that the user try's to input - as you will probably be aware MVC 2 throws an error for any HTML in the text. I use ViewModels and decorate my properties with filters from the DataAnotatio...

Why won't this mod_rewrite rule work (via .htaccess one specific url to another)

RewriteRule ^/tag/term$ /tag/term-expanded-here [R] ...

Javascript string replace with regex to strip off illegal characters

Need a function to strip off a set of illegal character in javascript: |&;$%@"<>()+, This is a classic problem to be solved with regexes, which means now I have 2 problems. This is what I've got so far: var cleanString = dirtyString.replace(/\|&;\$%@"<>\(\)\+,/g, ""); I am escaping the regex special chars with a backslash but I am h...

Regex in python to get javadoc-style comments in CSS

Hi there, I'm writing a python script to loop through a directory of CSS files and save the contents of any which contain a specifically-formatted javadoc style comment. The comment/CSS looks like this: /**thirdpartycss * @description Used for fixing stuff */ .class_one { margin: 10px; } #id_two { padding: 2px; } The regex...

C: Regex library with MinGW

How do I install a C regex into MinGW? I'm using it's gcc... I'm running Windows XP. I prefer a updated one. Thank you. ...

Jquery css selector using regular expressions

I have a DYNAMICALLY generated Navigation div <div id="WebPartWPQ9" > <table class="xm-ptabarea"> <tbody> <tr> <td nowrap="" class="tab"><a href="/somelink.aspx">Overview</a></td> <td nowrap="" class="tab"><a href="/anothersomelink.aspx">Financials</a></td> <td nowrap="" class="tab"><a href="/somemorelink.aspx">Newsfee...

How can I escape characters inside of this regular expression?

I have this function which will validate an email address. jsLint gives an error with the regular expression complaining about some of the characters being un-escaped. Is there a way to correctly escape them? var validateEmail = function(elementValue){ var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return...

Javascript regex grouping question

I want to be able to detect/pick apart strings like : tickets at entrance per person ballons pp tree planting i.e. a description followed by an optional "pp" or "per person" I try (.+)\s+(per person|pp) and that works; but the pp|per person suffix is then not optional. I try (.+)\s+(per person|pp)? or (.+)\s+(per person|pp){0...

What's the best way to escape user input for Regular Expressions in MySQL?

I'd like to take user input, denoted as $dangerous_string, and use it as part of a RegEx in a MySQL query. What's the best way to go about doing this? I want to use the user's string as a literal -- if it contains any characters that mean something in MySQL RegEx, those characters should not actually affect my Regular Expression. $dan...

java regex search replace issue

Hi all, I am new to java regex. I have a string that contains three occurences of the word 'TEST'. Each of this word is followed by ^ and I need to check if the content between 2 and and 3rd occurence of ^ is blank, if it is blank/empty search further to see if the content between the 5th and 6th occurence of the ^ is "" If it is "", ...

Replace string "white-spaces" with "comma" and remove all but 5 first words

Need a little help with string formatting... I have a string like this: Bmw m3 fully equipped and low mileage I need to replace whitespaces with commas, and also at the same time remove all special characters (all non number non letter characters except swedish å ä ö) Then I need to remove all but the first 5 words, or you could say ...

Checking for site reciprocal link

I'm trying to make a script that will load a desired URL (as entered by user) and check if that page links back to my domain before their domain is published on my site. I'm not very experienced with regular expressions and this is what I have so far: $loaded = file_get_contents('http://localhost/small_script/page.php'); // $loaded will...

Regex token replace in .NET?

I'm not sure if "token replace" is the right phrase but here is what i'm trying to do: In a string if I find two or more consecutive white spaces (\s) aka - spaces, new lines, tabs etc. I want to replace whatever it matched with only one instance of itself. Example: a b b would become a b b and: a b c Would become: ...

Avoiding processing special preg characters in replacement string

When using preg_replace() in PHP with strings generated at runtime, one can protect special regex characters (such as '$' or '+') in the search string by using preg_quote(). But what's the correct way to handle this in the replacement string? Take this code for example: <?php $haystack = '...a bit of sample text...'; $replacement = '\\...

Regular expression to parse a commented configuration file

Edit: I'm really just curious as to how I can get this regex to work. Please don't tell me there are easier ways to do it. That's obvious! :P I'm writing a regular expression (using Python) to parse lines in a configuration file. Lines could look like this: someoption1 = some value # some comment # this line is only a comment someoptio...

Can I get away with preg_replace() here or do I need to use preg_split()?

I need to split (but not preg_split()) my title on /, : or whitespace, in that order. For example, if I split on /, then I don't want to bother looking for : or whitespace. I thought I could do it with a regex (the input string here will never have HTML in it) $delimiters = array('/', ':', '\s'); $title = preg_replace('@(' . implode('...

regex: separating procedure/function from PL/SQL code

I am writing Perl regex code to separate out PL/SQL procedure from the package. Each procedure starts with the PROCEDURE key word and ends with END, But the END is for BEGIN, IF, or LOOP. There may be many BEGIN|IF|LOOP. Below is the kind of input, I want to separate each procedure. How can I do this? PROCEDURE LOG_ECS_MSG( MD_CURR C...

java regex - searching for empty content between two occurences of a search char

Hi all, I am new to java regex. Sorry for the long posting. I have a three requirements: 1a) I have a string that contains three occurences of the word 'TEST'. Each of this word is followed by ^ and I need to check if the content between 2 and and 3rd occurence of ^ is blank, if it is blank/empty search further to see if the content...

Java and .Net Regular Expressions

Difference between Java & .Net Framework Regular Expressions Pattern I am trying to convert My .Net Framework but patterns are not valid Can any one point out the major differences in regex patterns e.g. How would we name the grouping constructs in java, etc. ...