• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

How to match this

I need to match "[/ADDRESS]" using the following
$new_post =~ s/\[/ADDRESS\]/NEW/g;

the problem I have is how to get the first / to work thats part of the "[/ADDRESS]" string
0
kplonk
Asked:
kplonk
1 Solution
 
maneshrCommented:
kplonk,

"..how to get the first / to work thats part of the "[/ADDRESS]" string ..."

Can you explain, in plain english, what exactly you are trying to do?

It is best not to post any code, as it not only confuses things, but also flys in the face of providing you a working solution fast.

Let me know.
0
 
ozoCommented:
$new_post =~ s/\[\/ADDRESS\]/NEW/g;
#or
$new_post =~ s{\Q[/ADDRESS]}{NEW}g;
0
 
TsvetomirCommented:
ozo  gave you the good answer  [ and / are  special chars you need to escape them - to do this you have to add \ before the special char ie : \[ \/

(\Q treats all special chars as normal untill it it meets \E)

:)))
0
 
kplonkAuthor Commented:
Thats the way to do it, the odd things is that i had tried it but it did not work, must have been tired.
0
 
ozoCommented:
#or
$new_post =~ s!\[/ADDRESS]!NEW!g;
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now