Pattering matching /regular expression help

Hi all,

I need to do a simple filter to remove some odd character that get imported into my nodes [bulk import].

The characters are

ºº

and I need to replace them with a
<br />.

I've built a little filter module, which will do the trick, but my regex skills are , well, non existent.

I've tried

<?php
$text
= eregi('ºº','<br />',$text);
?>

to no avail.

Can anybody help?

Alan

Groups:
Login to post comments

try this

John Morahan - Thu, 2008-12-11 15:35

<?php
$text
= preg_replace('/ºº/', '<br />', $text);
?>


No dice...

alanburke - Thu, 2008-12-11 15:41

Hi John,
Thanks for the quick response.

No luck with that, I'm afraid.

I'm pretty sure the rest of the module is functioning.
If I try a simpler preg_replace [with a word in the text, for example], it seems to work fine.

For whatever reason, it doesn't 'see' those characters, and doesn't remove them.

Alan


Maybe a character set issue

John Morahan - Thu, 2008-12-11 16:04

Maybe a character set issue - are you saving your module file as UTF-8?


Hmm

alanburke - Thu, 2008-12-11 16:15

Maybe that's the issue.
I'll look into it further.


We're in the presence of greatness!

alanburke - Thu, 2008-12-11 16:22

Well done John,

My module file wasn't UTF-8 - it is now!

All good, thanks a million!

Alan


I can't tell, what are those

stella's picture
stella - Thu, 2008-12-11 16:00

I can't tell, what are those characters?


No idea!

alanburke - Thu, 2008-12-11 16:16

I don't even know what they're called myself!


Speed

jbligh - Thu, 2008-12-11 16:40

The simpler str_replace function would be faster than a full regular expression assuming it can handle the character encoding issue.


Alan: one of these days

scor's picture
scor - Thu, 2008-12-11 17:03

Alan: one of these days you'll get on IRC and understand what you are missing :p