Tag Archives: regex

regex for getting word right before brackets

I have various strings with different information but they all share one common characteristic: they contain the username of the requester with brackets right after it. Something like: "... paul [55] ..."… I am trying to write a regex that Continue reading

Tagged , | Leave a comment

Check which of two variants is the traditional and which the simplified Chinese

I’m getting inconsistent results from Google maps api,

|Head southwest on 吳江路/吴江路 toward 泰兴路/泰興路
|Head southwest on TRAD/SIMP toward SIMP/TRAD

Currently I am matching Chinese words with this regex ([^u0000-u0080]|/)+
Then I explode the matches and have pairs 吳江路 vs … Continue reading

Tagged , , , | Leave a comment

Regular expression to match single dot but not two dots?

Trying to create a regex pattern for email address check. That will allow a dot (.) but not if there are more than one next to each other.
Should match:
test.test@test.com
Should not match:
test..test@test.com
Now I know there are… Continue reading

Tagged , , , | Leave a comment

PHP preg_replace replace text unless inside brackets

I would like to use PHP’s preg_replace()… to search a text for occurrences of a certain word, and enclose that word in brackets, unless there are already brackets present. The challenge here is that I want to test for brackets Continue reading

Tagged , , , , | Leave a comment

Write an .htaccess rewrite rule excluding one file

I’m working with a framework and need to make a call to a specific file within a directory, however the directory is set up for url of all requests to index.php for the framework’s sake.
I have a file called… Continue reading

Tagged , , , | Leave a comment

PHP – Reading ftp text files and extract required data

This is my first php script. I actually code in vb.net.. I am making this licensing system for .net applications. This licensing system has a manager which the admin can easily control and view. Also Iam making a class library… Continue reading

Tagged , , , , | Leave a comment

Convert Notepad++ Regex to PHP Regular Expression

I’m trying to convert a Notepad++ Regex to a PHP regular expression which basically get IDs from a list of URL in this format:

http://www.example.com/category-example/1371937-text-blah-blah-blah-2012.html

http://www.example.com/category-example/1471337-text-blah-blah-2-blah-2010.html

Using Notepad++ regex function i get the output that i need in two steps Continue reading

Tagged , , | Leave a comment

Regexp ignore certain parts in string

I need to use regex for a string to find matching results.
I need to find the (.+?) but would like to ignore everything where it says (*) right now:

$regex='#<span class="(*)"><a href="/venues/(*)">(.+?)</a></span>#';

Instead of ignoring (* ), it echoes Continue reading

Tagged , , , | Leave a comment

preg_match , only works locally

This is the code that works, locally.

$str = <<<SSS
  <H1 class="prodname">Alison Raffaele Reality Base</H1>Foundation, Skintone 1 - Fairest&nbsp;1 fl oz (30 m)<p class="tip"><table id="TblProdForkSellCopy" width="100%" border="0"><tr><td class="contenttd"><p>Get full, flawless coverage with this luxurious oil-free formula. Continually refreshes and re-hydrates 

Continue reading

Tagged , | Leave a comment

PHP Regex specify multiple paths using glob()

glob("aaafolder/*php")
glob("bbbfolder/*php")
glob("cccfolder/*php")

Is it possible to simplify this?

glob("(?=aaafolder/*php)(?=bbbfolder/*php)(?=cccfolder/*php)")

The above returns nothing. Continue reading

Tagged , , , | Leave a comment
46 pages