I have a list of terms like volcano, glacier and so forth in my comments section. They look like this:
Volcano
Grass
Glacier
I want to add an s to the end of each word. This should be relatively easy but I suck at regular expressions. Any help in a find and replace format would be appreciated. I tried
Find: ^([\w]+)
Replace with: $1s
But that only seems to work on one word.
I would create an action group with 2 actions, assuming that the individual words are separated with a comma. If it is a space then use only the space.
Search:,_
(where the _ is a space)
Replace with: s,_
And the second action: of the type "Format value" for comment
Format string: %comment%s
This seems to work fine:
3 lines of COMMENT before applying the Convert Tag -> Tag for COMMENT
Convert Tag -> Tag with your regular expression as Format string:
$regexp(%COMMENT%,'^([\w]+)',$1s)
becomes (as already visible in the preview):
Thank you both for your input. It works! This is very much appreciated!
How about if there was two words in a line, like garbage bag, where you only have to add an s to the last word? I ended up using Find:(\b\w+\b) Replace:$1s and that was working for me other than the case with two words.
$regexp(%COMMENT%,(.)$,$1s)
This works for any amount of words. It just add a s
at the end of the entire string/line.
Hint: This solution no longer corresponds to the original title of the topic!
This also does not take into account any of the dumb English exceptions for plurals in some cases. In your example, "Grass" should be pluralized to "Grasses" adding "es" in this case. But I think this would be a tough one to automate!
Yeah, or man>men, woman>women, words like pyjamas, trousers that are already a plural, police, furniture that never gets a plural s ... and so on.
What about moose, sheep or shrimp?
Or the plural form of any of this words: Fun, Wisdom, Silence, Sugar, Coal, Spelling, Money, Help, Advice, Work, Butter, Love, News...
Yes, all of these and many more!
You all raise great points that I have run into. I know this can be done, as I have an actions I have taken from this site that will capitalize everything except certain words, using the "\b(grass|mass|pass...)\b" arguments, but this would be tougher because there are so many words to address and they do not follow the same format. If my regular expressions skill was not below floor level I might take a crack at it.
At least LyricsLover's "script" will allow me to go line by line instead of word by word, but still, the task will be arduous.
Thanks! I corrected the title.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.