?
Solved

How to match this

Posted on 2002-03-03
5
Medium Priority
?
146 Views
Last Modified: 2013-12-25
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
Comment
Question by:kplonk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 6838258
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
 
LVL 84

Accepted Solution

by:
ozo earned 80 total points
ID: 6838498
$new_post =~ s/\[\/ADDRESS\]/NEW/g;
#or
$new_post =~ s{\Q[/ADDRESS]}{NEW}g;
0
 
LVL 3

Expert Comment

by:Tsvetomir
ID: 6838555
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
 

Author Comment

by:kplonk
ID: 6839222
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
 
LVL 84

Expert Comment

by:ozo
ID: 6840160
#or
$new_post =~ s!\[/ADDRESS]!NEW!g;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question