Solved

How to match this

Posted on 2002-03-03
5
140 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
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 20 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
home folder path for users 4 85
Facebook React and SyntheticEvents 6 70
Selecting Right Partition 6 67
AWK Code gives empty file, why? 12 36
In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

790 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