Solved

How to replace bracket with space?

Posted on 2009-04-13
4
681 Views
Last Modified: 2012-05-06

My log is as below. I want to replace bracket with space. I have tried ~s/(/ /g; and ~s#(# #g; but it doesn't work. Does anybody know any way to do this?

Thanks very much!


From:
acl_Application_access permitted tcp 192.168.113.38(3394) 10.108.80.11(135)
acl_Application_access permitted tcp 192.168.201.57(3395) 10.108.80.11(1025)
acl_Application_access permitted tcp 192.168.34.169(3396) 10.108.80.11(445)
 
To:
acl_Application_access permitted tcp 192.168.113.38 3394 10.108.80.11 135
acl_Application_access permitted tcp 192.168.201.57 3395 10.108.80.11 1025
acl_Application_access permitted tcp 192.168.34.169 3396 10.108.80.11 445

Open in new window

0
Comment
Question by:howruaz9
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 300 total points
ID: 24131914
$log = '
acl_Application_access permitted tcp 192.168.113.38(3394) 10.108.80.11(135)
acl_Application_access permitted tcp 192.168.201.57(3395) 10.108.80.11(1025)
acl_Application_access permitted tcp 192.168.34.169(3396) 10.108.80.11(445)
';

$log  =~  s/[()]/ /g;
print $log;
0
 
LVL 10

Accepted Solution

by:
oleber earned 200 total points
ID: 24131975
probably is more like

$log = '
acl_Application_access permitted tcp 192.168.113.38(3394) 10.108.80.11(135)
acl_Application_access permitted tcp 192.168.201.57(3395) 10.108.80.11(1025)
acl_Application_access permitted tcp 192.168.34.169(3396) 10.108.80.11(445)
';

$log  =~  s/\(/ /g;
$log  =~  s/\)//g;
print $log;
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 300 total points
ID: 24131996
#or
s/\(/ /g,s/\)//g for $log;
0
 

Author Comment

by:howruaz9
ID: 24134024
Three methods work very well. Thanks so much ozo and oleber.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now