regex

iPhone Regular Expression Capture Groups

Since Apple now appears to be rejecting apps that link to libicucore (such as apps that utilize RegexKitLite), what is the best way to get regular expressions with capture group functionality to work from within an iPhone app? Should one statically compile ICU or PCRE (perhaps using the RegexKit PCRE wrapper)? ...

How can I use regex to grab the information on the END of a line?

For example, http://api.hostip.info/get_html.php?ip=12.215.42.19 When visiting that URL, it will return: Country: UNITED STATES (US) City: Sugar Grove, IL IP: 12.215.42.19 I want to set Sugar Grove, IL to a variable, after visiting that URL. How would I make it find the City, and then set it to a variable? ...

Question about regular expression evaluation using RegexKitLite

I am trying to get all css link from html like this segment of code: <link href="http://media.ticketmaster.com/en-us/css/1c84b57773d8f594407f0b0b78d67aba/tm/default.css" rel="stylesheet" type="text/css" /> <link type="text/css" rel="stylesheet" href="http://media.ticketmaster.com/en-us/css/1c84b57773d8f594407f0b0b78d67aba/tm/datepicker....

PHP Regex for IP to Location API

How would I use Regex to get the information on a IP to Location API This is the API http://ipinfodb.com/ip_query.php?ip=74.125.45.100 I would need to get the Country Name, Region/State, and City. I tried this: $ip = $_SERVER["REMOTE_ADDR"]; $contents = @file_get_contents('http://ipinfodb.com/ip_query.php?ip=' . $ip . ''); $pattern ...

create anchors in a page with the content of <h2></h2> in PHP

Well I have a html text string in a variable: $html = "<h1>title</h1><h2>subtitle 1</h2> <h2>subtitle 2</h2>"; so I want to create anchors in each subtitle that has with the same name and then print the html code to browser and also get the subtitles as an array. I think is using regex.. please help. ...

Rewrite redirects the simple regex to base file.

I'm trying to do the basic mod_rewrite clean URL trick, where /category/item rewrites to /category/index.php?id=item. In the /category directory, I have this in my .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteBase /category/ RewriteRule ^(.+)$ index.php?id=$1 [L] It sends the request to the index.php script jus...

PCRE to find all possible matching values

I am using PCRE in PHP, and I need to find a way to generate say an array of all possible matching values. Any ideas? For example if I had R[2-9]{1} I would want: R2 R3 R4 R5 R6 R7 R8 R9 Thanks for the help, -Eric ...

How to validate a correct domain name and sub domain in php

How to remove www and validate a valid domain name. Valid Domain domain.com subdomain.domain.com sub-domain.domain.com Invalid Domain www.domain.com www.subdomain.domain.com http://www.domain.com/ http://www.subdomain.com/ www.domain.com/folder/ How the code? $domain ='www.domain.com/folder/'; if() { // validate here } ...

Javascript, Regex - I need to grab each section of a string contained in brackets

Here's what I need in what I guess must be the right order: The contents of each section of the string contained in square brackets (which each must follow after the rest of the original string) need to be extracted out and stored, and the original string returned without them. If there is a recognized string followed by a colon at the...

deleting unwanted xml nodes

I have a bunch of .xml files with nodes that are causing uncessesary complications. I would like to remove these nodes but ensure that thier children are preserved (not the heirarchical structure but the data). Eventually I want to take the data from each .xml and build a dataframe. It seems like xmlTreeParse along with xmlToList will...

Why do these regular expressions execute slowly in Java?

Hi, I am trying to use regular expressions to determine what format the user have applied when entering input in a textbox. The regular expressions are as follows: (\\s?[" + alphabet + "]{9,9})+ To determine whether the input is one or more strings of length 9 in a given alphabet, possibly separated by whitespace. (>[\\w\\s]+\\n[" +...

Does this violate the 'leftmost longest' principle?

I am trying to write a regex to recognize a single line of text, with underscore ( _ ) recognized as a line continuation character. For example, "foo_\nbar" should be considered a single line, because the "foo" ends in an underscore. I am trying: $txt = "foo_\nbar"; print "$&\n" if $txt =~ /.*(_\n.*)*/; However, this prints only: f...

Matching a^n A^n with regular expression

hi, we're learning about the difference between regular languages and regex, and the teacher explained that the language a^n b^n is not regular, but she said that most regex flavors can match a^n A^n and she gave this problem for our extra credit homework problem. we've been struggling for a couple of days now, and could really us...

Preg_match help for finding count

HI all i have a string <font size="+1"><b>Open Directory Sites</b></font> (1-20 of 10000)<p> i need to get 10000 as answer .. how i use preg_match ??? Note: this is implortant that the multiple occurance of match Thanks in advance ...

Regular expression for matching a variety of types of numbered lists

I'd like to create a (PCRE) regular expression to match all commonly used numbered lists, and I'd like to share my thoughts and gather input on way to do this. I've defined 'lists' as the set of canonical Anglo-Saxon conventions, i.e. Numbers 1 2 3 1. 2. 3. 1) 2) 3) (1) (2) (3) 1.1 1.2 1.2.1 1.1. 1.2. 1.3. 1.1) 1.2) 1.3) (1.1) (1.2) (...

how can i read the vale of first = sign(or the the value of middle = sign) not the last value

i read the answer regarding the answer of this code function delete_subscriber(){ var id=this.href.replace(/.*=/,''); this.id='delete_link_'+id; if(confirm('Are you sure you want to delete this subscriber?')) $.getJSON('delete.php?ajax=true&id='+id, remove_row); return false; } but i want the value read through regular expression of ...

ONE question regular expression PHP

Count character '_' in start line example : subject = '_abcd_abc'; // return 1 or subject = '__abcd_abc'; // return 2 or subject = '___abcd_abc'; // return 3 everyone help me ~ I use PHP ...

Regex for Date problem

I have string for example: 06.07.2010 (tor.) I would like to extract only 06.07.2010 using a regex, but the following is not working correctly: ^([0-9]{1,2}).([0-9]{1,2}).([0-9]{4,4})$ ^([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.][0-9]{4}$ Can someone tell me what is wrong here? ...

Regex to match all unicode quotation marks

Is there a simple regular expression to match all unicode quotes? Or does one have to hand-code it like this: quotes = ur"[\"'\u2018\u2019\u201c\u201d]" Thank you for reading. Brian ...

PHP: replacing a specific char in a range with preg_replace

Hi everybody! Lets say I'm trying to replace every "A" character with a "B", inside two [lol] tags. For example: "[lol]It's greatA really isA[/lol]" will become "[lol]It's greatB really isB[/lol]" I was trying to work something myself but it was in vain. The closest i got is this: preg_replace("%(\[lol\])"."(.*?)([A]+?)(.*?)"."(\[/...