How do I make an expression to match this below: (including spaces , whitespaces, other characters in the numbers)? Example:
asdasd (S)FS-980/24/BS/02 , asdasd
ffff (S)FS-9525/23/BS/12ss, IP000003587
FSW-952/24/BSB/02
FS-2/24/F/02
FS-4444/23/F/11
I mean if invoice number : FS -444 4/23/F/11 - it also correct to: FS-4444/23/F/11, or FS-4444g/23g/F/1g1
i try like this: ...FS(W)-../.{2}/..(.)/\s.{2}
You could update your pattern to get the matches first. Then do a replacement over those matches, and remove the characters that you don't want.
To match the strings:
The pattern matches:
(?:\([A-Z]+\))?Optionally match(followed by 1+ chars A-Z and then)FS[A-Z ]*-matchFSfollowed by optional chars A-Z or spaces\dMatch a digit(?:[^\n,()-]*\w)?Optionally match any char except what is listed in the character class, and end on a word characterIf you want to match a space without a newline in C# you can also use
\p{Zs}Regex demo
To replace the unwanted characters over the matched parts:
This pattern will match all lowercase characters at the beginning of the string before the
-and match all lowercase chars a-z or spaces at the end of the string, not crossing any characters other then what is listed in the character class present in the positive lookahead assertion.See a Regex demo and a C# demo.
Output