![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| adding one string at the beginning of each line in a file | siba.s.nayak | UNIX for Dummies Questions & Answers | 3 | 08-13-2009 02:45 AM |
| Deleting part of a string enclosed in brackets | pcwiz | Shell Programming and Scripting | 10 | 07-30-2009 02:16 AM |
| substitution of string in brackets | jacks | Shell Programming and Scripting | 4 | 12-05-2008 01:14 PM |
| To substitute a string in a line to another string | Niroj | Shell Programming and Scripting | 4 | 10-31-2008 04:23 AM |
| substitute string according line number | nir_s | Shell Programming and Scripting | 4 | 07-19-2005 08:25 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to substitute brackets in the beginning of string in perl?
Hi, I have a string like this user can specify different query sets that is why "or" is mentioned: Code:
$string="[[:<:]](";
or
$string="[[:<:]]((";
or
$string="[[:<:]](((";
or
$string="[[:>:]](((((";
What i have to do is substitute these brackets in the beginning. I tried like this: Code:
if($string=~/\[\[:<:\]\]\(/)
{
$string=~s/\[\[:<:\]\]\(/\(\[\[:<:\]\]/g;
}
elsif($string=~/[[:<:]]\(\(/)
{
#same here
}
elsif($string=~/[[:<:]]\(\(\(/)
{
#same here
}
elsif($string=~/[[:<:]]\(\(\(\(/)
{
#same here
}
elsif($string=~/[[:<:]]\(\(\(\(\(/)
{
#same here
}
If statement i can use but i will be not be sure how many brackets will be there to substitute in the beginning? I have to avoid this if loop!! The output should be like this. Code:
$string="\([[:<:]]"; or $string="\(\([[:<:]]"; or $string="\(\(\([[:<:]]"; etc like this all these different string examples are based on the users query sets that is why i just mentioned or such that user can give either like first string ( [[:<:]]\( ) or like second string ( [[:<:]]\(\( ). How can i put or substitute brackets in the beginning of the sting? Any ideas??? Regards Vanitha |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|