regex


Have trouble identifying and deleting a line - should be simple


So this should be easy, but I just can't seem to get it right. I have the following data:
4131942 Door Assy, LH Ref 249R/RP
15 #7002668 - Rev. A - June, 2006
1. 6110010 Bolt, #10-24 x 1/2” Flat Head
and I want to delete the middle line.
This is the most recent iteration of the statement that I am using:
sed -i '/(^[(0-9)][(0-9)](.*)[#][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)](.*))/d'
I have used multiple variation and different regexps, to no avail.
What am I missing here?
Your regex is ok, but you need to use sed -r in order to enable extended regular expressions.
Try:
sed -ri '/(^[(0-9)][(0-9)](.*)[#][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)][(0-9)](.*))/d' file
Alternatively, simplify it to:
sed -ri '/^[0-9]{2}.*#[0-9]{7}.*/d' file

Related Links

Tabulation of data in perl
Perl regular expression / substitution for nested phrases
YAPE::Regex::Explain not working with use 5.014;
Optional JFlex lookahead with End of File
Regular expression that allows square-brackets
Reg Expression - split 2 string in between <h3> tags
Perl: Multiple lookbehind regex in a single regex expression
mod_rewrite to nginx rewrite rules
Perl Binary/PCAP regex
Why does grep match all lines for the pattern “\'”
regular expression for C if statementch
Regular expression for search name of methods in java files
Recommendation - Resource/book/pocketbook on regex in SED [closed]
Perl: composing regex thru interpolation when subexpr has capture
RegExp regular expression find & replace whole words only
Given a certain regex pattern, re-arrange and manipulate the contents of a cell

Categories

HOME
apache-spark
matlab
vb.net
gwt
sharepoint-2013
dynamics-crm-365
compliance
isis
geolocation
google-cloud-dataproc
antlr
weblogic11g
sweetalert
splunk
wget
activerecord
xorg
higher-order-functions
development-environment
plots.jl
orchardcms-1.10
aar
ssrs-tablix
amadeus
round-robin
pydev
ghost-blog
many-to-many
sencha-touch-2
jqplot
parallax
simple-html-dom
mediacodec
android-imageview
svgpanzoom
dokuwiki
cloudinary
complex-networks
extraction
packaging
response
bem
google-slides
essbase
integer-programming
pulseaudio
move
simplesamlphp
manifoldjs
domdocument
libev
html-lists
breach-attack
ifc
measurement-protocol
ubuntu-15.04
xnamespace
tealeaf
ellipsis
ng-annotate
webclient-download
cufft
sql-server-2016-express
pager
geneos
bash-completion
intrinsics
vimeo-ios
js-of-ocaml
linqtocsv
wand
document-ready
python-dragonfly
xirr
text-alignment
tun
ubiquity
netbsd
equinox
keypad
theorem-proving
epplus-4
mui
short
requiredfieldvalidator
asciiencoding
pdf-scraping
webcal
cassette
cakephp-2.1
clean-urls
browserid
code-structure
ad-hoc-distribution
zmodem
sticky-footer
tipsy
force.com
mknetworkkit
semantic-zoom
jammit
eye-detection
high-traffic
maemo
xquery-update
resharper-4.5
sharepoint-feature
web-based
xlink

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App