Generation of Regex for Perl script


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Generation of Regex for Perl script and delete

I want to generate regex for this kind of expression and want to find and replace.

like :
----> [-reset, enable;+-]


basically i want to find anything that match a pattern like this [-any string with or without space-] and remove the whole thing
Please looking for some suggestions

Last edited by utkarshkhanna44; 5 Days Ago at 08:35 AM..
# 2  
Code:
$ echo '[string 1 ] apple [ string 2]' | perl -pi -e ' s/[[][^]]*]//g; '
 apple


Last edited by anbu23; 5 Days Ago at 09:08 AM..
This User Gave Thanks to anbu23 For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Help with understanding this regex in a Perl script parsing a 'complex' string
newbie_01
Hi, I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does...... UNIX for Beginners Questions & Answers
3
UNIX for Beginners Questions & Answers
Perl, RegEx - Help me to understand the regex!
alex_5161
I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in...... Shell Programming and Scripting
2
Shell Programming and Scripting
Report generation using perl script
vel4ever
Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f...... Shell Programming and Scripting
4
Shell Programming and Scripting
shell or perl script using grep and regex
termeric
Hi, I have file stored in a directory containing information about subnet mask and next hop address in the following format 10.1.1.0/16, 255.255.0.0, 10.1.1.1 10.1.2.0/16, 255.255.0.0,10.1.2.1 here 10.1.1.0/16 represent range of ip address 10.1.1.1-10.1.1.16 given say an IP address...... Shell Programming and Scripting
1
Shell Programming and Scripting
Converting perl regex to sed regex
suntzu
I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)...... Shell Programming and Scripting
1
Shell Programming and Scripting

Featured Tech Videos