php - Replace string if the string is not part of a larger string using regex in javascript -


i'm trying write function uppercase words in textarea i'm having trouble, these words part of other words , want uppercase them when standing alone.

e.g.: want uppercase or when not in word before. these words can written in multitude of ways, @ start of line, between 1 or more whitespace characters or in this: (somethingsomething)or(somethingelse) , more, depending on way other people write query code.

i had idea of working regex, i'm not skilled enough work out every possibility of writing these words.

i have no way of changing textarea other, better plugins or editors it's part of functioning script.

any helpful idea appreciated.

edit: 1 additional question

i got helpful answers question, thank everyone. have additional question though. if, other checking it's not part of word, want check it's not preceded or followed . period. tried adding (?!\.) @ beginning of it, doesn't work @ all. there way check well?

//edit: never mind, figured out. it's \b(?!\.)something(?!\.)\b check @ start , end of word.

something this? ( °_• )

var txt="or text or before (.)or(.) anywhere or";  console.log(txt.replace(/\bor\b/gi,"or"));       // "or text or before (.)or(.) anywhere or" 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -