$organized =~ s/(\w+)[^(^\d+)(\s)]/z/g;
In a regular expression [ ... ] is a character set. What you told perl to look for is a word followed by ONE character that is not a '(', ')','^' or '+' and neither a number nor a space character.
Since the first word in your lines seems to be a single digit number (at least in your sample data), it is just coincidence that it isn't replaced. Any word of length 1 will not be replaced. Also any word aka element with a number or any of the other characters above as last character would not be replaced.
In short, if these lines work for you, it probably is just a coincidence
Maybe you should use more variable test data to check for edge cases, for example try:
5 suf 6 va7 7dra de) e+f ed ed 5z5 nu3 b +4 s 5 + 33 44 55 z5 zb zzz zb z5 4zz
PS: Please reread my first post, I had to correct an error in my regex
In reply to Re^3: regular expessions question: (replacing words)
by jethro
in thread regular expessions question: (replacing words)
by $new_guy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |