Mars 0 Posted October 24, 2011 Report Share Posted October 24, 2011 Hello all, I try to replace the space only in Regex to ":" Example:Here is the whole sentence:{top rated|major} {ten|10} kids Halloween costume I would like it to be:{top:rated|major} {ten|10} kids Halloween costume I use find regular expression ({[a-zA-Z|].+})to select the sentence from the article {top rated|major} {ten|10} But, dont know how to just replace the space to ":" in the selection and then put it back to the original article. The attachment is the ubot4 file I test.Please help. Thanks a lot. regex_sample.ubot Quote Link to post Share on other sites
Frank 177 Posted October 24, 2011 Report Share Posted October 24, 2011 It may be difficult. Do you want to replace all spaces within {}'s? Or just the one instance? Or just when it's between 'top' and 'rated'? Frank Quote Link to post Share on other sites
Mars 0 Posted October 24, 2011 Author Report Share Posted October 24, 2011 Hello Frank, I would like to replace all spaces within {}.Thanks a lot. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted October 24, 2011 Report Share Posted October 24, 2011 Use this regex string \s for spaces then replace it with : in replace regex expression. Quote Link to post Share on other sites
Mars 0 Posted October 24, 2011 Author Report Share Posted October 24, 2011 Use this regex string \s for spaces then replace it with : in replace regex expression. How do I only select the spaces within { }?I try to use \s but it selects all spaces in the article.And, I cannot find the way to only select the spaces within { and }.Thanks. Quote Link to post Share on other sites
Mars 0 Posted October 25, 2011 Author Report Share Posted October 25, 2011 Hello all, I still cannot find the way to only select the spaces within { and }Anyone can help?Thanks a lot. Quote Link to post Share on other sites
Legend 181 Posted June 18, 2012 Report Share Posted June 18, 2012 I would just use the replace command rather than regex... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.