WeiDU provides the keyword STRING_CONTAINS_REGEXP which probably does what you want. You'll need to specify the search string as a regular expression however. The same is true for REPLACE_TEXTUALLY, you'll need to specify the string to replace as a regular expression.
Let's take this example:
OUTER_TEXT_SPRINT oldstring ~Longsword +1~ ACTION_IF ((~%oldstring%~ STRING_CONTAINS_REGEXP ~ \+1~) == 0) BEGIN OUTER_INNER_PATCH_SAVE newstring ~%oldstring%~ BEGIN REPLACE_TEXTUALLY ~ \+1~ ~~ END PRINT ~Old string: "%oldstring%"~ PRINT ~New string: "%newstring%"~ END ELSE BEGIN PRINT ~String does not contain " +1".~ END
It searches for " +1" in the given string and removes it when found.
Just curious. How do you handle item names such as "Bone Club +2, +3 vs. undead"? There are surely a number of mods that use similar naming schemes for their own items.
Or you could simply remove everything after the enchantment factor. For example, REPLACE_TEXTUALLY ~ \+[1-6].*$~ ~~ changes "Bone Club +2, +3 vs. undead" into "Bone Club".
Comments
Let's take this example: It searches for " +1" in the given string and removes it when found.
REPLACE_TEXTUALLY ~ \+[1-6].*$~ ~~
changes "Bone Club +2, +3 vs. undead" into "Bone Club".