When testing an answer for another user's question I found something I don't understand. The problem was to replace all literal \t \n \r characters from a string with a single space.
Now, the first pattern I tried was:
/(?:\\[trn])+/
which surprisingly didn't work. I tried the same pattern in Perl and it worked fine. After some trial...
I have preg_match_all('/[aäeëioöuáéíóú]/u', $in, $out, PREG_OFFSET_CAPTURE);
If $in = 'hëllo' $out is:
array(1) {
[0]=>
array(2) {
[0]=>
array(2) {
[0]=>
string(2) "ë"
[1]=>
int(1)
}
[1]=>
array(2) {
[0]=>
string(1) "o"
[1]=>
int(5)
}
}
}
The position of o should be 4. I've read about this problem on...
In some obscure situations a regular expression like "/^match/" works in the exact oposite way matching a line that is "something else", and the only way to fix it is to put the whole regex inside braces ... "/^(match)/", why is that happening?
...
Hi all,
I'm getting the following message for some php I have to use but did not write:
Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/html2fpdf.php on line 466
This is line 466:
if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
I tried simply replacing with preg_match, but it couldn't re...
I'm trying to create a textmate snippet that will transform this:
HELLO WORLD<br />
SAY ANYTHING
To this:
hello world say anything
Any help?
...
I was reading through some of the responses in this question and saw that a few people said that recursive regular expressions were not strictly speaking regular expressions.
Why is this?
...
i m just wondering if we can do this with preg replace
like if there's time like
1h 38 min
can change to
98 mins
2h 20 min
can change to
140 mins
or just suggest me any other random function to this is simpler way
thanks
...
I am trying to match a series of text strings with PCRE on PHP, and am having trouble getting all the matches in between the first and second.
If anyone wonders why on Earth I would want to do this, it's because of Doc Comments. Oh, how I wish Zend would make native/plugin functions to read Doc Comments from a PHP file...
The following...
Is there a way for PCRE regular expressions to count how many occurrences of a character it encounters (n), and to stop searching after it has found n occurrences of another character (specifically { and }).
This is to grab code blocks (which may or may not have code blocks nested inside them).
If it makes it simpler, the input will be...
Regular expressions can become quite complex. The lack of white space makes them difficult to read. I can't step though a regular expression with a debugger. So how do experts debug complex regular expressions?
...
Possible Duplicate:
The Hostname Regex
I'm trying to use pcrepp (PCRE) to extract hostname from url.
the pcre regular expression is as same as Perl 5 regular expression.
for example:
url = "http://www.pandora.com/#/volume/73";
// the match will be "http://www.pandora.com/".
I can't find the correct syntax of the regex for ...
Hello.
This is my javascript regex pattern:
url = "http://www.amazon.com/gp";
hostname = /^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)/.exec(url) || [];
// would return "www.amazon.com"
the above regex extracting the hostname from a given url.
I ...
I have this simple piece of code in c++:
int main(void)
{
string text = "http://www.amazon.com";
string a,b,c,d,e,f;
pcrecpp::RE re("^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)");
if(re.PartialMatch(text, &a,&b,&c,&d,&e,&f))...
I have a html file that has invoice details
I would like to know is there a way that I can retrieve only the invoice numbers and store it separately in my sql database using php?
<p>Invoice ID: 0201</p>
<p>MID : Q987</p>
<p>Desciption: Solid Concrete Blocks</p>
<p>Qty: 7478 Blocks </p>
<p> </p>
<p>Invoice ID: 0324</p>
<p>MID : Q44...
I have two string variables which are both file paths. The code that worked used ereg which is deprecated, so I'm trying to rewrite it using preg_match:
Old code that worked:
$path1 = quotemeta($path);
ereg("$path1(.*)$", $path2, $matches);
Using preg_match which doesn't seem to work:
$path1 = quotemeta($path);
preg_match("/$path1(....
I've got a problem with RegEx and Delphi 2k9 (Win32). I get the following Error:
First chance exception at $7C812AFB. Exception class Exception with message 'TPerlRegEx.Compile() - Please specify a regular expression in RegEx first'.
I've got the latest version of TPerlRegEx from the website. Using its defualt settings (Using DLL)
I...
Hi,
I have the following php code in a utf-8 php file:
var_dump(setlocale(LC_CTYPE, 'de_DE.utf8', 'German_Germany.utf-8', 'de_DE', 'german'));
var_dump(mb_internal_encoding());
var_dump(mb_internal_encoding('utf-8'));
var_dump(mb_internal_encoding());
var_dump(mb_regex_encoding());
var_dump(mb_regex_encoding('utf-8'));
var_dump(mb_regex...
I need to convert a string of text containing a long url into the same string but with a tinyurl (using the tinyurl api). eg. convert "blah blah blah /http://example.com/news/sport blah blah blah" into "blah blah blah http://tinyurl.com/yaeocnv blah blah blah".
How can it be done? PLEASE NOTE I added a slash before the long url as I'm o...
Is there a way to obtain the C++ equivalent of Perl's PREMATCH ($`) and POSTMATCH ($') from pcrecpp? I would be happy with a string, a char *, or pairs indices/startpos+length that point at this.
StringPiece seems like it might accomplish part of this, but I'm not certain how to get it.
in perl:
$_ = "Hello world";
if (/lo\s/) {
$...
How can I convert
ereg_replace(".*\.(.*)$","\\1",$imgfile);
to
preg_replace... ?
?
I'm having trouble with it?
...