How to validate a regular expression text not allowing everything in white space?

-2

I need to validate a line from a text file, where I already have part of the expression, but I lack the part where from position X to position Y I have 30 characters that correspond to the type string that can contain anything, which would correspond to the ER ". {30}", but I can not allow the 30 characters to be all empty, as if it were a mandatory text field. Any ideas how to do it?

    
asked by anonymous 25.07.2014 / 19:06

1 answer

1

A regex

^\S+$

It has a match if the string is not empty and has at least one character that is not whitespace. So, you can break your initial string into two parts, one from the beginning to the X-1 character and the other the rest. In the first you make the match that matters and in the second the regex above will guarantee that it is not empty and that it contains at least one whitespace character.

    
25.07.2014 / 19:44