Re: Validating multiple contents



On Fri, Oct 17, 2008 at 3:50 PM, Matthew Moss <matt@xxxxxxxxx> wrote:

On Oct 17, 2008, at 12:15 AM, Bala Krishnan wrote:

Hi
If we want to validate result page with single text content we will
use

ie.text.include?(" Particular content ")

suppose if i want to validate page with multiple content like

German rails
NGINX
how to use ruby for this validation?


["German rails", "NGINX"].any? { |str| ie.text.include?(str) }

This will return true if any of the strings are found in ie.text. Replace
any? with all? to return true only if all of the strings are found.

More obscure but kind of cute:

Regexp.union("German rails", "NGINX").match(ie.text)

Regexp.union creates a regexp that matches any of the parts. They're
regexp-escaped, too.

.



Relevant Pages

  • Re: Regular expression 0 - number range.
    ... To validate an ISO 8601 Gregorian Date String, ... GMT date/time strings require little extra work. ... And I'm reasonably sure that I've seen a full RegExp Gregorian date ... Date)) or an optimal non-Object method. ...
    (comp.lang.javascript)
  • Re: Is there a maximum length of a regular expression in python?
    ... basically a list of all known norwegian postal numbers and the corresponding place with | in between. ... your horrendously long regexp)? ... validate the number and name. ... sensible option. ...
    (comp.lang.python)
  • Re: New utf8string design may make UTF-8 the superior encoding
    ... It is a trivial single-pass loop, no try-and-rescan as suggested by the regexp model. ... I completed the detailed design on the DFA that would validate and translate any valid UTF-8 byte sequence into UTF-32. ... validating byte sequences as valid UTF-8 and dividing these sequences ...
    (microsoft.public.vc.mfc)
  • Re: Regular expression 0 - number range.
    ... written a RegExp which will properly validate all 8-digit Gregorian ... Yours works in my Firefox 3.6.17, and Safari 5.0.5, and Chrome 11.0. ... Purely validating an ISO 8601 string. ...
    (comp.lang.javascript)
  • Re: Search method or RegExp?
    ... Two two functions I found below both validate an email address correctly, ... The first one uses the "search" method of a string, and the second uses a RegExp object. ... have written more input validation programs than I care to mention..frankly the best way is to scan letter by letter with a state machine and a series of nested switch statements. ...
    (comp.lang.javascript)