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

htaccess redirectmatch regular expression to avoid infinite loop
String replacing nested JSON in Scala
Find all instances of “Replace” but not “.Replace”
Simplify a regex - multiple discrete options
Redirecting case insensitibe URL in apache
PostgreSQL regex check start with Latin and alpha character
Antlr4 define a operator which can be Unary or Binary
How to get a group value from grep?
VS 2013 can't find lib file from Boost toolkit
Image files have got changed but pictures look the same
REGEX in perl, start matching from the n occurrence of elem e
Regex - Include up to a certain character and exclude occurences after
Regex pattern to match groups starting with pattern
Python3 Double Quote Parsing and Detection
Regular expression for finding a substring not surrounded by other characters [duplicate]
How to write regex for redirection

Categories

HOME
ios
lsf
orbeon
apt-get
graylog2
amazon-kinesis
stack
twitter-digits
api.ai
openvpn
addeventlistener
httpbuilder-ng
winsql
payment-processing
ibm-midrange
eloqua
editor
plots.jl
rgb
smartsheet-c#-sdk-v2
jmespath
h.264
advantage-database-server
accelerated-mobile-page
aikau
csom
precision
google-oauth2
mathdotnet
physics
android-security
flexjs
editorconfig
asp.net-identity-2
ruamel.yaml
apex-code
chai
subtotal
nav
outlook-vba
jdom-2
json-rpc
qmake
ulimit
mergesort
mobile-browser
autofocus
http-status-code-500
android-gps
abbyy
view-source
javascript-security
haste
tastypie
swift-package-manager
topojson
git-config
ocsp
sizeof
telecommunication
cufft
rras
xlform
pakyow
java-gstreamer
subroutine
tag-helpers
filenet-content-engine
dnx
android-gpuimageview
esky
user-registration
equinox
wss4j
gevent-socketio
movie
javaw
vendor
express-jwt
linguistics
nhunspell
twill
dirpagination
qt4.7
repeating
visual-assist
adlds
virtual-earth
word-2010
headless-browser
zmodem
payment-services
jetspeed2
staging
machine.config
hunchentoot
indextank
webshop
dynamic-websites
code-statistics
large-teams
user-testing

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