regex


Using Bash Regular Expressions to replace part of matched results


I have a file with lines that appear as:
1/foo/bar/
2/foo/bar/
3/foo/bar/
I would like to take two inputs, the first of which to match to the number. This is relatively simple. Then, I'd like to replace 'bar' with whatever is input for the second argument. Is this possible?
This smells like a homework assignment, but anyway, if you're on Linux (bash) "sed" should be available to match a line and do a replacement in that line, otherwise passing through non-matching lines unchanged.

Related Links

regex from first character to the end of the string
How can I recognize the following group of strings using a grammar or regex?
htaccess redirect begins with
grep through binary file
Printing Text on Perl with RegEp
Regexp for substitution of anything other than numbers and 'N/A'
This regex is inefficient. Why does it crash Sublime Text 2's stack?
Posix regex in Postgresql to extract from quoted text?
Regular expression sequence matching
Perl change number to words
regex to match value up to 2 decimal
What is the mappings.ts file and how should it be set up in Tritium?
Symfony2 IBAN Validator returns false for valid UK IBAN
Regex to find anchor tags which are without http or https in the href attribute
What's the difference between [:space:] and [:blank:]?
Regex to replace &nbsp with

Categories

HOME
validation
codeigniter
vb.net
collections
python-3.5
garbage-collection
amazon-kinesis
format
wikipedia-api
oracle-adf
jbpm
sweetalert
build.gradle
eps
scope
openui5
yii2-advanced-app
lighttpd
apex
message
w2ui
nsmutableattributedstring
smartcard
netcdf
liferay-aui
padding
mathdotnet
number-formatting
text-parsing
reformatting
scatter-plot
webcenter
double-click-advertising
docker-image
ecmascript-4
bezier
linechart
tibco-ems
compass-lucene
keyboard-maestro
simplesamlphp
azure-cdn
sharpziplib
stroke
unityscript
jvm-arguments
findall
jeditorpane
sscanf
hapi.js
texture2d
webpagetest
activity-diagram
insert-update
oracle-policy-automation
target-platform
bash-completion
mongolab
main-activity
storage-duration
flexigrid
subroutine
genetic
readline
hjson
appv
android-listfragment
netbsd
cbc-mode
spatial-index
genexus-gam
smarty2
adserver
words
mysql5
opensc
ash
pkcs#10
short
disk-io
antisamy
preon
ramdisk
data-dictionary
confirmation
mod-python
transport-stream
flash-cs4
wow64
scrollpane
chromeless
teamcity-7.0
tipsy
hpple
objcopy
sharepoint-timer-job
custom-tag
indextank
pinging
msn-messenger
help-authoring

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