Replace by Array?

General questions about using WildEdit

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
PeteTheBloke
Posts: 39
Joined: Fri Apr 22, 2005 8:15 am
Location: N. Ireland
Contact:

Replace by Array?

Post by PeteTheBloke »

Not sure how to phrase this but PHP users will know what I mean.

I want to search for 1 2 and 3 and replace them with 5 6 and 7 respectively.

In PHP I might use str_replace(array(1,2,3) , array(5,6,7), string )
PeteTheBloke
Posts: 39
Joined: Fri Apr 22, 2005 8:15 am
Location: N. Ireland
Contact:

Post by PeteTheBloke »

Came up with a solution. Maybe it'll help someone.

I put all the lookup list in a table in a database:

1 fred
2 bert
3 george

etc. I had 260-odd rows.

Then I filled another table like this:
INSERT INTO tbl_name SET other_ref = (SELECT uid FROM tbl_lookup WHERE name = 'fred') , etc. etc.

I was able to use normal regex to make the 25000 lines from csv to SQL as above. And now it's all working.
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Search for: (1)|(2)|(3)

[X] Regular expression

Replace with: ?1x:?2y:?3z

[ ] Literal replacement [i.e., not selected]

Options
Replacement format syntax
[X] Extended
Search for conditional "extended format" in the help.
Post Reply