Search found 85 matches

by ragax
Wed Sep 25, 2013 4:43 pm
Forum: Regex
Topic: Search Lists which are in a table cell only
Replies: 8
Views: 12725

Re: Search Lists which are in a table cell only

Hi again. Thought I'd take a quick close look. This code addresses your original question (please run it). Simple replace so no need for a callback. $string = '<table> <tr> <td>Test</td> </tr> <tr> <td> Text here <ul> <li>Test1</li> <li>Test2</li> </ul> Text </td> </tr> '; $regex = '~(?s)<td>(?!.*?<...
by ragax
Wed Sep 25, 2013 4:17 pm
Forum: Regex
Topic: Search Lists which are in a table cell only
Replies: 8
Views: 12725

Re: Search Lists which are in a table cell only

Hi radiks, I don't have time to look in detail today, but at first glance it looks to me that you may not be using preg_replace_callback properly. It looks like the function you are calling uses a preg_match. But the idea for the function you call is that you pass it the array of matches, then that ...
by ragax
Tue Sep 24, 2013 8:03 pm
Forum: Regex
Topic: Search Lists which are in a table cell only
Replies: 8
Views: 12725

Re: Search Lists which are in a table cell only

Hi radiks, To do this in regex, you need to use regex lookahead and lookbehind . To give you an example, this pattern will match from an opening <td> to the next <li> that occurs before the closing </td>. After that, you can start adding your capture groups etc. (?s)<td>(?!.*?</td>.*?<li>).*?<li> It...
by ragax
Tue Sep 24, 2013 1:14 pm
Forum: Regex
Topic: Search Lists which are in a table cell only
Replies: 8
Views: 12725

Re: Search Lists which are in a table cell only

I think you're going to need preg_replace_callback.
You can then (break)(your)(match)(into)(capture)(chunk) and reassemble everything however you want.

The easiest example of this is actually not on the preg_replace_callback page but on the anonymous function page.
by ragax
Tue Sep 17, 2013 8:00 pm
Forum: Regex
Topic: RegexBuddy 4 Released
Replies: 0
Views: 6253

RegexBuddy 4 Released

For the many of you who, like me, are big fans or Jan's RegexBuddy, today is a big day: RegexBuddy 4 is out! It's a spectacular release. I've been waiting for some of the features for a long time (\K, recursion), but Jan went even further. For instance you can convert between different languages. Fr...
by ragax
Tue Aug 06, 2013 12:52 am
Forum: Regex
Topic: regex with pipes?
Replies: 5
Views: 12607

Re: regex with pipes?

Yes, commas are kind of crazy, that's why I like to use them sometimes. For everyday use, though, tildes: less risky, more elegant. consider looking somewhere else for more in-depth explanations and guidance. Our sticky mentions a few things; regular-expressions.info is another good place. But for m...
by ragax
Mon Aug 05, 2013 11:31 pm
Forum: Regex
Topic: regex with pipes?
Replies: 5
Views: 12607

Re: regex with pipes?

Couldn't have said it better than requinix! Other delimiters I like are tildes and commas --- but I may be alone on that one. I'll add that the forward slash is one of the worst you could choose as a standard delimiter because sooner or later you'll want to match urls, which will give you this kind ...
by ragax
Sun Jul 28, 2013 5:28 pm
Forum: Databases
Topic: Debugging MySQL code .. a few tips.
Replies: 28
Views: 100478

Re: Debugging MySQL code .. a few tips.

Debugging MySQL code .. a few tips. To get this (ancient) mostly off-topic thread back on track, two tips I didn't find above: 1. Add a comment to the top of each query, for instance: $myquery = "# from jamesbond.php | get spy names query SELECT name FROM.... "; When you have a large app ...
by ragax
Sun Jul 28, 2013 5:06 pm
Forum: PHP - Theory and Design
Topic: Why not learn OOP before Procedural?
Replies: 9
Views: 13990

Re: Why not learn OOP before Procedural?

Why not learn OOP before Procedural? One of the major points of OOP is to make it more efficient to manage a team of programmers. But can you say today that you will always be managed, working in a team? When working around the house, the bloke who can't do anything without reaching for his whizz-b...
by ragax
Thu Jul 25, 2013 8:48 pm
Forum: PHP - Security
Topic: Security Resources
Replies: 36
Views: 152990

Re: Security Resources

Chris Shiflett's Security Workbook Excellent PDF covering security in PHP. Is anyone aware of another good book on the topic? Yes Chris's book is excellent, but I've been wondering if there have been new developments since it came out in 2005, and I've been feeling hungry for more as I get back in ...
by ragax
Thu Jul 25, 2013 8:38 pm
Forum: PHP - Security
Topic: how to find php error log
Replies: 6
Views: 13680

Re: how to find php error log

Note that you can point error_log to a file with any name, e.g. myprettyPHPlog.txt Preferably store it above the html root so it is not world-accessible. After you've done all this, it may still not work. One common problem (which happened to me on a server not long ago) is permissions on the log fi...
by ragax
Thu Jul 25, 2013 7:25 pm
Forum: Regex
Topic: what is tool to check online regex
Replies: 5
Views: 13145

Re: what is tool to check online regex

The list of online regex tools seems to be mushrooming endlessly. I suspect that making an online regex checker is an assignment in some computer science classes. The result is a plethora of regex checkers with me-too features—and it becomes hard to know which ones to use, particularly if you're mar...
by ragax
Fri Aug 10, 2012 10:24 pm
Forum: Databases
Topic: Which database to use: SQLyog or HeidiSQL
Replies: 4
Views: 5716

Re: Which database to use: SQLyog or HeidiSQL

Okay, I installed HeidiSQL a few days ago and had a decent look around. I can see why people like it, the interface is clean and it's a big step up from phpMyAdmin. That being said, there are many features that I love having in SQLyog and that I couldn't find in Heidi: - copying a DB from one server...
by ragax
Thu Aug 09, 2012 5:23 pm
Forum: Regex
Topic: How to look for a number from 1 to 4 chars long
Replies: 2
Views: 7114

Re: How to look for a number from 1 to 4 chars long

A regex option:

Code: Select all

$string = 'width="581"';
$regex = '~(?i)width="(\d{1,4})~';
$hit = preg_match($regex,$string,$match);
if($hit) echo $match[1].'<br />';
Now go read up on regex to understand why that works.
:D
by ragax
Wed Aug 08, 2012 3:59 pm
Forum: PHP - Security
Topic: PHP DSO security
Replies: 3
Views: 8100

Re: PHP DSO security

Hi rhecker, Good to hear from you and great to know that your VPS is working well! That really pleases me. You get what you pay for. > alternatives like nginx Just to clarify, nginx does not replace Apache. If I understand, it's some kind of caching proxy in front of Apache. If you become interested...