ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You need to be a little more general, that looks really specific. How do you know what spaces get replaced by underscores and what spaces stay as they were? syllables?
1. the word remains as it is.
2. each set of characters enclosed in braces are merged using underscore
eg. [ a bc d ] becomes a_bc_d
that is, the left brace and space between left brace and first character is eliminated.similarly, the right brace and space before it.
all spaces inbetween are made underscore.
3. one space between each of the groups enclosed by braces.
eg. [a bc d ] [e fg h] becomes a_bc_d e_fg_h
here's a long example
according [ ah ] [ k ao r ] [ d ih ] [ ng ]
has to become
according ah(one space)k_ao_r(one space)d_ih(one space)ng
echo '
point [ p oy n t ]
pointed [ p oy n ] [ t ah d ]
according [ ah ] [ k ao r ] [ d ih ] [ ng ]' |
sed -r ':a s/(\[[^]]*) /\1_/; ta; s/\[_|_\]//g'
point p_oy_n_t
pointed p_oy_n t_ah_d
according ah k_ao_r d_ih ng
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.