[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
how do you replace a string of 4 digits with the same 4 digits,
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 6
Thread images: 2
File: sed.jpg (28 KB, 401x312) Image search: [Google]
sed.jpg
28 KB, 401x312
how do you replace a string of 4 digits with the same 4 digits, but padded with parentheses?

e.g. 2016 --> (2016)

i know how to find the 4 digit string, but not how to replace it

grep -E -o "[0-9]{4}"
>>
>>54901068
install gentoo
>>
File: cirno.jpg (47 KB, 420x420) Image search: [Google]
cirno.jpg
47 KB, 420x420
let string = format!("({})", string);
>>
to pad with strings "foo" and "bar"

sed -E 's/([0-9]{4})/foo\1bar/g'
>>
>>54901068
export TMP=1234
echo "($TMP)"
>>
>>54901068
(define (wrap str)
(string-append "(" str ")"))
Thread replies: 6
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.