Tag Archives: express

Regular expression to find “src” attribute of HTML “img” element in PHP

Questions: I have a string, inside of that I have an image: “<p><img src=”http://yahoo.com/testfolder/userdata/editoruploadimages/confused man.jpg” /></p>” I could not fetch the image URL with my regular expression. My code is: preg_match_all(“/src=([^\\s]+)/”, $questArr_str, $images); This code stops its execution when it encounters the space in the image name. It only returns “http://yahoo.com/testfolder/userdata/editoruploadimages/confused The returned string should… Read More »

Compile Error: Cannot use isset() on the result of an expression

Questions: I’m getting this error in a app I am migrating from SF2.0.x to SF2.7: [1] Symfony\Component\Debug\Exception\FatalErrorException: Compile Error: Cannot use isset() on the result of an expression (you can use “null !== expression” instead) at n/a in /var/www/html/reptooln_admin/app/cache/dev/twig/68/7f/63589dd3687cb849dd68e6b6c10aa99eda1d82f95a5f3ac52a864d200499.php line 39 I don’t know what is failing or how to fix this so I need… Read More »

Regular expression to remove CSS comments

Questions: I want to write the regular expression in php for matching the line within a double and single quotes. Actually I am writing the code for removing comment lines in css file. Like: “/* I don’t want to remove this line */” but /* I want to remove this line */ Eg: – valid… Read More »

Regular expression for parsing CSV in PHP

Questions: I already managed to split the CSV file using this regex: “/,(?=(?:[^\”]\”[^\”]\”)(?![^\”]\”))/” But I ended up with an array of strings that contain the opening and ending double quotes. Now I need a regex that would strip those strings of the delimiter double quotes. As far as I know the CSV format can encapsulate… Read More »

match url pattern in php using regular expression

Questions: I want to match a url link in wall post and replace this link with anchor tag, for this I use the regular expression below. I would like the match 4 types of url: http://example.com https://example.com www.example.com example.com preg_replace(‘@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@’, ‘<a href=”$1″>$1</a>’, $subject); This expression matches only first two types of url. If I use… Read More »

PhpStorm is not receiving xdebug connections : PhpStorm event log : Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'

Questions: I configured everything for PhpStorm and xdebug to work, I’m running Ubuntu 14.04. the connection back to the IDE is not established, and I get this in the IDE event Log Cannot accept external Xdebug connection: Cannot evaluate expression ‘isset($_SERVER[‘PHP_IDE_CONFIG’])’ – Osama Salama 13 mins ago I’ll put together configuration values I configured in… Read More »

Implementing goMongoDB-like Query expression object evaluation

Questions: I’ve been looking for a MongoDb-like ( http://docs.mongodb.org/manual/applications/read/#find, docs.mongodb.org/manual/reference/operators/ ) query expression object evaluation function implementation or a class. It may cover not all the advanced features, and should have extensible architecture. MongoDB-like query expression objects are easy for understanding and usage, providing ability to write clean, self-explaining code, because both query and objects… Read More »