1

I am attempting to isolate a particular section of a line, and delete everything else after it.
Below are some example strings on what the general formatting of the file looks like. Each one of these lines I am attempting to isolate the Collection-ID.Package-name and remove the.(Version)

DGL1PLAN_PUT_PFC.FCA#FKS.(CAD17_2013-01-30-21.35.29)
DSN8CC91.DSN8CLTC.(2015-01-14-16.33.06.616783)
DSNAOCLI.DSNCLICS.(UQ40167)
DSNJAR.DSNX9DIJ.(UK81051)

Into:

DGL1PLAN_PUT_PFC.FCA#FKS
DSN8CC91.DSN8CLTC
DSNAOCLI.DSNCLICS
DSNJAR.DSNX9DIJ

I have not figured out how to delete the lines, but I have figured out (I think) how to isolate them by themselves. I am currently using ^.*(?=..(CAD)) to highlight everything before the .() on the lines. I am learning Regex and to my understanding and google searches:
^ is the beginning of the string
. finds any character except newlines
* finds 0 or more of the previous type
( begins search
?= is positive lookahead
..(CAD) is the search term I used to get it to highlight the string I want to isolate
) ends the search
I am unsure of how to delete the excess but have managed to highlight the portion I want to keep.
Here is an image of what I've figured out so far:

Attempt

2 Answers2

0

You can use regex: ^(.*)\.\(CAD.*\) and in replace field enter $1. This will search for string, followed by (CAD, then any symbols and ). And print only 1st group (before dot and open bracket)

If you want the same for other lines use regex: ^(.*)\.\(.*\)

Here is demonstration how it work: https://regex101.com/r/wWC24q/1

Romeo Ninov
  • 7,848
0

Use this regex:

\.\(.*

And replace with nothing (blank).

Explantation:

  • \.\( - match . and ( literally next to eachother
  • .* - match anything after those in a greedy way, to match as much as possible. Keep in mind that . matches newline option needs to be turned off, else it would match multiple lines.

This is a bit simplier than the other answer as it does the opposite - it deletes the redundant part and leaves the beginning in tact.

Destroy666
  • 12,350