Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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