Merge 2 regex patterns -



Merge 2 regex patterns -

i have text file contains (this on excerpt):

third doc season 7 051 spearhead space 4 3—24 jan 1970 052 doc , silurians 7 31 january—14 march 1970 053 ambassadors of death 7 21 march—2 may 1970 054 inferno 7 9 may—20 june 1970 season 8 055 terror of autons 4 2—23 jan 1971 056 mind of evil 6 30 january—6 march 1971 057 claws of axos 4 13 march—3 apr 1971 058 colony in space 6 10 april—15 may 1971 059 dæmons 5 22 may—19 june 1971

note basic line pattern ^###\t.*\t?\t.*$ (i.e every line has 3 tabs \t).

i remove after the episode title, this:

third doc season 7 051 spearhead space 052 doc , silurians 053 ambassadors of death 054 inferno season 8 055 terror of autons 056 mind of evil 057 claws of axos 058 colony in space 059 dæmons

currently tested next patterns in gedit:

([^\t]*)$ # replaces not after lastly `\t', # incl `\t', lines *does not* contain `\t'

then tried ‘make selection’ of lines, should regexed (?=(?=^(?:(?!season).)*$)(?=^(?:(?!series).)*$)(?=^(?:(?!doctor$).)*$)(?=^(?:(?!title).)*$)(?=^(?:(?!specials$).)*$)(?=^(?:(?!mini).)*$)(?=^(?:(?!^\t).)*$)(?=^(?:(?!anim).)*$)).*$ — does work intended, not know how combine ([^\t]*)$.

since fields separated tabs, need utilize cut obtain 2 first fields:

cut -f1,2 drwho.txt

for knowledge, same awk:

awk -f"\t" '$3{print $1"\t"$2}!$3{print $0}' drwho.txt

explanation: awk works line line, f parameter defines fields delimiter.

$3 { # if field3 exists print $1"\t"$2 # display field1, tab, field2 } !$3 { # if field3 doesn't exist print $0 # display whole record (the line) }

regex

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -