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

How to replace bracket with space?


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
howruaz9
Asked:
howruaz9
  • 2
3 Solutions
 
ozoCommented:
$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
 
oleberCommented:
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
 
ozoCommented:
#or
s/\(/ /g,s/\)//g for $log;
0
 
howruaz9Author Commented:
Three methods work very well. Thanks so much ozo and oleber.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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