Regex in perl

Posted on 2014-04-16
Last Modified: 2014-04-18

How do I write a regex in perl that trims each line at "] to the end of that line.

So my result file would look like:


Original file:
0eef2427e-fdde-1341a-b5d1-1bc214721332451.pdf"] was not found or subfolder ["DailyNews"] not created.
0eef2427e-fdde-1341a-b5d1-1b24214721332451.pdf"] was not found or subfolder ["GlobalServicesInc"] not created.
Question by:LuckyLucks
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 250 total points
ID: 40005697
Use this:

or, if you really need to stop at the first "], use this:

LVL 26

Accepted Solution

wilcoxon earned 250 total points
ID: 40005777
More efficient (no capture - just removing the unwanted chars) would be this:

Open in new window


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating the data using Oracle DBD module. 5 67
Exchange 2010 Transport Rule Regex 28 108
.properties file to call function/method 9 61
Perl modules on linux ec2 3 104
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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