regex

How to verify an email address using c# code?

Possible Duplicate: Validating an email Address in C# I require the c# code for email address verification. I don't want to use validator control now. Anybody can help me with code using RegEx? thx in advance ...

registration form checking order in php?

i have a problem with this registration form, im checking the password and username, this is the process im doing it in? php: $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['pass'])); //check if username is valid if (ereg("^[a-zA-Z0-9_\-]+$", $username)){ ...

tumblr avatar img resize (solved) need help with calls to load additional comments

Hello, I'm relatively hopeless with JavaScript writing, and I'm trying to resize the default tumblr avatar image on a notes page. Currently there is no way to include a large avatar in your notes, so I'm trying to use a basic regular expression to replace the dynamically generated URL. A user's avatar is generated into something like t...

How can I make this regular expression extract contents of certain HTML elements in my document?

I've spent a good few hours trying to get this regular expression to work and I'll I've got so far is one big headache! I'm using cURL to load a page into variable $o. Now somewhere in this page is the following: <tr valign="top"> <td>value1</td> <td>value2</td> <td align="right">value3</td> </tr> And this is repea...

Read in CLI argumnet, then use regex's to look for it. -Python

Hello all! Sorry if this is probably a simple fix but I can't think of one. I am trying to take a command line argument (in this case a name) and search through a file hierarchy and keep track of the number of times that name comes up. I was just wondering how to store the CL input and then search through files using a regular expression...

How can I parse this HTML with a regular expression in PHP?

Hi, I'm working on regular expression to find a whole heap of text that sits inside <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; and a tag that says end of menu... which looks like this: <!--END MENU--> This is the code i wrote but it's not spitting o...

Case insensitive regex in javascript

Hi I want to extract a query string from my URL using JavaScript, and I want to do a case insensitive comparison for the query string name. Here is what I am doing: var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0; But the above code ...

How do I substitute with an evaluated expression in Perl?

There's a file dummy.txt The contents are: 9/0/2010 9/2/2010 10/11/2010 I have to change the month portion (0,2,11) to +1, ie, (1,3,12) I wrote the substitution regex as follows $line =~ s/\/(\d+)\//\/\1+1\//; It's is printing 9/0+1/2010 9/2+1/2010 10/11+1/2010 How to make it add - 3 numerically than perform string concat?...

Permalinks with mod_rewrite

Is it possible to make a short URL rule so that every word (except the root folders) after http://mydomain.com/ will get redirected to /index.php?permalink=$1 ? examples: http://mydomain.com/ - goto index.php (standard). http://mydomain.com/word - goto index.php?permalink=word My .htaccess looks like this right now: Options +Follo...

How to appendReplacement on a Matcher group instead of the whole pattern?

I am using a while(matcher.find()) to loop through all of the matches of a Pattern. For each instance or match of that pattern it finds, I want to replace matcher.group(3) with some new text. This text will be different for each one so I am using matcher.appendReplacement() to rebuild the original string with the new changes as it goes...

negative lookbehind and greedy quantifiers in php

I'm using a regex to find any URLs and link them accordingly. However, I do not want to linkify any URLs that are already linked so I'm using lookbehind to see if the URL has an href before it. This fails though because variable length quantifiers aren't allowed in lookahead and lookbehind for PHP. Here's the regex for the match: /\b(?...

C# Parsing Text Within Quotes

I'm developing a simple little search mechanism and I want to allow the user to search for chunks of text with spaces. For example, a user can search for the name of a person: Name: John Smith I then "John Smith".Split(' ') into an array of two elements, {"John","Smith"}. I then return all of the records that match "John" AND "Smith"...

PHP regex - valid float number

I want user only input 0-9 and only once "." patt = /[^0-9(.{1})]/ 1.2222 -> true 1.2.2 -> false (only once '.') help me , thank ! ...

Python regular expression to match file-date.txt

I am trying to match file names in the format filename-isodate.txt >>> DATE_NAME_PATTERN = re.compile("((.*)(-[0-9]{8})?)\\.txt") >>> DATE_NAME_PATTERN.match("myfile-20101019.txt").groups() ('myfile-20101019', 'myfile-20101019', None) However I need to get the filename and -isodate parts in seperate groups. Any suggestions and/or exp...

Matching long string(full postcode) agains short string(start of postcode) in mysql

I have a table that contains a list of the starting letters in a post code e.g. LS for Leeds and SO for Southampton. I want to match these against a user entered full postcode e.g. LS19 1AB. I've looked into using LIKE and some regexp stuff in my query but I'm struggling to find a way to do this the right way round. Any ideas? ...

How to select a part of string?

How to select a part of string? My code (or example): <div>some text</div> $(function(){ $('div').each(function(){ $(this).text($(this).html().replace(/text/, '<span style="color: none">$1<\/span>')); }); }); I tried this method, but in this case is selected all context too: $(function(){ $('div:contains("text...

& sign in url rewriting

hi how can i get full url with & sign RewriteRule category/(.*)$ categories.php?url=$1 [PT,L] my url is category/pets-&-wets/ but when i get echo $_GET['url']; it shows only pets- any suggestions thanks ...

Regular Expression problem in erb Rails

Dear All, I need to apply a regular expression in html.erb <% taxon_name.strains.each do |strain| %> <% taxon_name.strain_appendices.each_with_index do |strain_appendice, i| %> <% if ((strain_appendice.data_source =~ /LPSN/) && (strain.relevance =~ /^ty(.*)ain$/))%> <% if i == 0 %> <p><%= strain_appendice.appendix %> </p> <% strain.st...

How to extract all occurences of a specific tags of an xaml/xml file?

Let's say I need to extract all solid-brushes and linear-gradient brushes in a dictionary resource file using C#. How can I do it? Please help! This question can be extended to be more general like "How to find the multiple-lines match(es) when searching a file using C#?" ...

Regex in Python

I have the following string: schema(field1, field2, field3, field4 ... fieldn) I need to transform the string to an object with name attribute as schema and the field names as another attribute which is a list. How do I do this in Python with a regular expression? ...