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

Asked

Viewed 1,273 times

-3

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, that would correspond to the ER ". {30}", but I cannot allow the 30 characters to be all empty, as if it were a mandatory text field. Anyone has any idea how to do?

1 answer

1

A regex

^\S+$

has a match if the string is not empty and has at least one character that is not whitespace. Therefore, Voce can break its initial string into two parts, one from the beginning to the character X-1 and the other the rest. In the first Voce the match that matters and in the second the above regex will ensure that it is not empty and that it contains at least one non-whitespace character.

  • Unfortunately, this does not suit me, I need an expression that treats without me doing content breaking. Imagine that I will have a string that starts with "01", then has 5 characters, and then ends with "03"... The 5 middle characters cannot be " ", could be "01abc 03" or "01 . 03", but cannot be "01 03". I can demand that it be different from something, as in the case, other than " "?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.