Hi.
I'm doing some kind of own templates system. I want to change
<title>{site('title')}</title>
Into function "site" execution with parameter "title". Here's
private function replaceFunc($subject)
{
foreach($this->func as $t)
{
$args = explode(", ", preg_replace('/\{'.$t.'\(\'([a-zA-Z,]+)\'\)\}/', '$1', $subject));
...
Nah, looks like it was hosting fault.
Who can make this code shorter?
private function replaceFunc($subject)
{
foreach($this->func as $t)
{
preg_match_all('/\{'.$t.'\([a-zA-Z,\']+\)\}/i', $subject, $res);
for($j = 0; $j < sizeof($res[0]); $j++)
{
preg_match('/\([a-...
In the PHP manual of PCRE, http://us.php.net/manual/en/pcre.examples.php, it gives 4 examples of valid patterns:
/<\/\w+>/
|(\d{3})-\d+|Sm
/^(?i)php[34]/
{^\s+(\s+)?$}
Seems that / , | or a pair of curly braces can use as delimiters, so is there any difference between them?
...
For example, for this string,
div.img-wrapper img[title="Hello world"]
I want to match the first space but not the second space (which is enclosed in []). What is the regex?
...
I need a regex for finding all .h, .c, and .cpp files in a folder. Help?
[no, this isn't homework, I just don't have time to learn regexes right now]
...
I want to parse markdown style links, but I'm having some trouble matching the reference style ones. Like this one: [id]: http://example.com/ "Optional Title Here"
My regex gets the id and the url, but not the title.
Heres what I have:
/\[([a-zA-Z0-9_-]+)\]: (\S+)\s?("".*?"")?/
I go through and add the references to a hashtable. th...
I am using python and would like a simple api or regex to check for a domain name's validity. By validity I am the syntactical validity and not whether the domain name actually exists on the Internet or not.
...
Hello Experts ,
I Want to validate the phone number in this format i.e +919981424199,+91231456789,....
I am using Asp.net +c#2008 for developing web site.for this i have used the Regular Expression validation control->property->Validation Expression="[0-9]+(,[0-9]+)*".
But this accept the number as 919981424199,.....
User may be enter ...
Hello,
Let's suppose that we have such HTML code. We need to get all <a href=""></a> tags which DO NOT contain img tag inside it.
<a href="http://domain1.com"><span>Here is link</span></a>
<a href="http://domain2.com" title="">Hello</a>
<a href="http://domain3.com" title=""><img src="" /></a>
<a href="http://domain4" title="">...
How can I get a string that only contains a to z, A to Z, 0 to 9 and some symbols?
...
How do I write a swtich for the following conditional?
If the url contains "foo", then settings.base_url is "bar".
The following is achieving the effect required but I've a feeling this would be more manageable in a switch:
var doc_location = document.location.href;
var url_strip = new RegExp("http:\/\/.*\/");
var base_url = url_strip...
I am working on a project that pulls data from JMS queue using PHP and Zend Framework. The HTTP client response is below. All I need is the XML string.
I came up with /(.*)<\/RequestDetails>/gs which tests ok on http://gskinner.com/RegExr/ but the preg_match call is returning an empty matches array.
I'm going to continue to hunt ar...
I'm trying to extract richard123 using php preg_replace but there are a lot of white spaces and new lines and I think because of that my regexp doesn't work .
The html can be seen here :
http://pastebin.com/embed_iframe.php?i=vuD3z9ij
My current preg_match is :
$find = "/< tr bgcolor=\"F0F0F0\" valign=\"middle\">< td align=\"left\">< ...
This is more out of curiosity than anything else, as I'm failing to find any useful info on Google about this function (CORE::substcont)
In profiling and optimising some old, slow, XML parsing code I've found that the following regex is calling substcont 31 times for each time the line is executed, and taking a huge amount of time:
...
Ive tried to use the Dom model with no bloody luck, getElementByID just doesnt work for me.
I loathe to resort to a regex but not sure what else to do.
The idea is to replace a <div id="content_div"> all sorts </div> with a new <div id="content_div"> NEW ALL SORTS HERE </div> and keep anything that was before or after it in the string....
Hello,
I have a grep expression using cygwin grep on Win.
grep -a "\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u" all_fbs.txt > rockon_fbs.txt
Once I identify the emoticon class, however, I want to strip them out of the data. However, the same regexp above within a sed results in a syntax error (yes, I realize I could use /d instead of //g, but t...
I am new to JavaScript
i need a regular expression which
allows both of this forms
for example :
http://www.google.com
www.google.com
...
Here is what I'm trying to accomplish. I have an object coming back from
the database with a string description. This description can be up to 1000
characters long, but we only want to display a short view of this. So I coded
up the following, but I'm having trouble in actually removing the number of
words after the regular expression ...
I'm writing a program in .net where the user may provide a large number of regular expressions. For a given string, I need to figure out which regular expression matches that string (if more than one matches, I just need the first one that matches). However, if there are a large number of regular expressions this operation can take a v...
Here's the code I'm running:
import re
FIND_TERM = r'C:\\Program Files\\Microsoft SQL Server\\90\\DTS\\Binn\\DTExec\.exe'
rfind_term = re.compile(FIND_TERM,re.I)
REPLACE_TERM = 'C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\DTExec.exe'
test = r'something C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTExec.exe somethin...