Welcome Guest, Not a member yet? Register   Sign In
I hate Regex
#5

[eluser]meigwilym[/eluser]
Not being an expert either, but I don't think that you need much regexing for this.

Take the first line for example, you need to match a string that starts with '<B><A ><FONT COLOR=”#00000” SIZE=“2” FACE=“arial”>' and ends with '</FONT></B>'. Thank simply remove them from the string, and what you have left is the column title.

Code:
&lt;?php

# string
$s = 'klhklghfdjskg <B><A NAME="999999999"><FONT COLOR="#00000" SIZE="2" FACE="arial">ColumnTitle</FONT></B> fdsfsdf dfsdf ';

# expression
$p = '/<B><A NAME="999999999"><FONT COLOR="#00000" SIZE="2" FACE="arial">([a-zA-Z0-9 ]*)<\/FONT><\/B>/';


preg_match($p, $s, $m);

var_dump($m);

The above code will return

Code:
array(2) {
  [0]=>
  string(88) "<B><A NAME="999999999"><FONT COLOR="#00000" SIZE="2" FACE="arial">ColumnTitle</FONT></B>"
  [1]=>
  string(11) "ColumnTitle"
}

I'm sure you can pick the rest of it up.

Here's an excellent tutorial and cheatsheet

http://neverfear.org/blog/view/Regex_tut...___Part_1/

http://www.addedbytes.com/cheat-sheets/r...eat-sheet/

Best,

Mei


Messages In This Thread
I hate Regex - by El Forum - 01-08-2009, 10:49 AM
I hate Regex - by El Forum - 01-08-2009, 11:03 AM
I hate Regex - by El Forum - 01-08-2009, 11:03 AM
I hate Regex - by El Forum - 01-08-2009, 11:24 AM
I hate Regex - by El Forum - 01-08-2009, 11:27 AM
I hate Regex - by El Forum - 01-08-2009, 11:35 AM
I hate Regex - by El Forum - 01-08-2009, 11:36 AM
I hate Regex - by El Forum - 01-08-2009, 11:41 AM
I hate Regex - by El Forum - 01-08-2009, 12:12 PM
I hate Regex - by El Forum - 01-08-2009, 01:26 PM
I hate Regex - by El Forum - 01-08-2009, 02:42 PM
I hate Regex - by El Forum - 01-08-2009, 02:50 PM
I hate Regex - by El Forum - 01-08-2009, 03:07 PM
I hate Regex - by El Forum - 01-08-2009, 03:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB