Remove all letters from specific word except the first
I have a load of files named
Firstname Secondname_001
Firstname Secondname_002
and i want them to be
Firstname S_001
how can i specify to remove everything either 2 characters after the space or from the second character of word 2
Firstname Secondname_001
Firstname Secondname_002
and i want them to be
Firstname S_001
how can i specify to remove everything either 2 characters after the space or from the second character of word 2
Try Remove pattern...
Pattern: [^ ]* \w\K[^_]*
Use regular expressions
Edit....
More simply...
Pattern " \w\K[^_]*"
(note: pattern starts with space)
Pattern: [^ ]* \w\K[^_]*
Use regular expressions
Edit....
More simply...
Pattern " \w\K[^_]*"
(note: pattern starts with space)
Reply to #2:
oh i see... you need to include the caret to signify the character.....
lol, i was so close.
and what does the K do?
oh i see... you need to include the caret to signify the character.....
lol, i was so close.
and what does the K do?
Reply to #3:
"^" means "NOT"
So [^xyz] matches any character not listed (ie NOT x,y or z)
The metacharacter \K is an instruction not to include the preceding matched characters in the preceding match.
Thus the regex "[^ ]* \w\K" must match a string of any number of non-space characters followed by a space and a single word character but the matched characters are not included in the final text to be removed.
The remainder of the regex, "[^_]*", then matches any characters until an underscore is encountered - and this string is removed.
"^" means "NOT"
So [^xyz] matches any character not listed (ie NOT x,y or z)
The metacharacter \K is an instruction not to include the preceding matched characters in the preceding match.
Thus the regex "[^ ]* \w\K" must match a string of any number of non-space characters followed by a space and a single word character but the matched characters are not included in the final text to be removed.
The remainder of the regex, "[^_]*", then matches any characters until an underscore is encountered - and this string is removed.