im a seasoned programmer but a regex newb. ive read some excellent
tutorials over the years, but i still often find myself starting all
over with baby steps when it comes to regexes. dunno why.
i need to plug in a regex into a software tool that validates a
string. for this particular string, i dont care *what* the value is,
just that it has one. what is the best way to write this supremely
easy requirement?
Fist of all i think it is easier to check without regexes using built-in functions like IsEmpty() function or logical "is Not NULL" check Calling for regex library will take additional time.
As for regex approach: 1) I think a presence of non-space character is a sign that the field contains a value. So the regex would be simple:
\S
2) If you are happy with just spaces or tabs or any other invisible characters, as well ..... In this case the regex would be just the all-capturing dot: .
Can you see it well above ? :)
Lack of boundaries \b and anchors (^, $, \A, \Z) ensures that this regex allows this any symbol to be located in any place of a target string (in the beginning, at the end, in the middle)
On Wed, Nov 4, 2009 at 10:54 PM, SpaceMarine <spacemar...@mailinator.com> wrote:
> hello,
> im a seasoned programmer but a regex newb. ive read some excellent > tutorials over the years, but i still often find myself starting all > over with baby steps when it comes to regexes. dunno why.
> i need to plug in a regex into a software tool that validates a > string. for this particular string, i dont care *what* the value is, > just that it has one. what is the best way to write this supremely > easy requirement?
> Fist of all i think it is easier to check without regexes using
> built-in functions like IsEmpty() function or logical "is Not NULL"
> check
> Calling for regex library will take additional time.
> As for regex approach:
> 1) I think a presence of non-space character is a sign that the field
> contains a value.
> So the regex would be simple:
> \S
> 2) If you are happy with just spaces or tabs or any other invisible
> characters, as well .....
> In this case the regex would be just the all-capturing dot:
> .
> Can you see it well above ? :)
> Lack of boundaries \b and anchors (^, $, \A, \Z) ensures that this
> regex allows this any symbol to be located in any place of a target
> string (in the beginning, at the end, in the middle)
> On Wed, Nov 4, 2009 at 10:54 PM, SpaceMarine <spacemar...@mailinator.com> wrote:
> > hello,
> > im a seasoned programmer but a regex newb. ive read some excellent
> > tutorials over the years, but i still often find myself starting all
> > over with baby steps when it comes to regexes. dunno why.
> > i need to plug in a regex into a software tool that validates a
> > string. for this particular string, i dont care *what* the value is,
> > just that it has one. what is the best way to write this supremely
> > easy requirement?
i'm using HP's Quick Test Pro, an enterprise scripting tool designed
to record and verify front-end application use (regression testing).
in it, designating a GUI textbox with the \S pattern (meaning, the
textbox may contain anything) does not work; tests don't pass.
however, using .* as the pattern does work.
sm
On Nov 5, 3:19 pm, SpaceMarine <spacemar...@mailinator.com> wrote:
> > Fist of all i think it is easier to check without regexes using
> > built-in functions
> impossible in this scenario. thus my post :)
> \S sounds like the winner.
> thanks!
> sm
> On Nov 5, 1:39 am, Eugeny Sattler <eugeny.satt...@gmail.com> wrote:
> > Fist of all i think it is easier to check without regexes using
> > built-in functions like IsEmpty() function or logical "is Not NULL"
> > check
> > Calling for regex library will take additional time.
> > As for regex approach:
> > 1) I think a presence of non-space character is a sign that the field
> > contains a value.
> > So the regex would be simple:
> > \S
> > 2) If you are happy with just spaces or tabs or any other invisible
> > characters, as well .....
> > In this case the regex would be just the all-capturing dot:
> > .
> > Can you see it well above ? :)
> > Lack of boundaries \b and anchors (^, $, \A, \Z) ensures that this
> > regex allows this any symbol to be located in any place of a target
> > string (in the beginning, at the end, in the middle)
> > On Wed, Nov 4, 2009 at 10:54 PM, SpaceMarine <spacemar...@mailinator.com> wrote:
> > > hello,
> > > im a seasoned programmer but a regex newb. ive read some excellent
> > > tutorials over the years, but i still often find myself starting all
> > > over with baby steps when it comes to regexes. dunno why.
> > > i need to plug in a regex into a software tool that validates a
> > > string. for this particular string, i dont care *what* the value is,
> > > just that it has one. what is the best way to write this supremely
> > > easy requirement?
> the \S pattern (meaning, the
> textbox may contain anything) does not work; tests don't pass.
> however, using .* as the pattern does work.
I think it is because of the following.
If the software requires "the whole string should be matched",
indeed .* is the right thing to use.
if the software applies "find a substring is enough"
approach , then \S should suffice.
\S might be not supported - in this case [^\s] which is the same, can
be used.