[ale] perl regex.... again
Geoffrey Myers
lists at serioustechnology.com
Tue Mar 1 07:59:58 EST 2011
Ron Frazier wrote:
> I don't know perl, but don't flame me. I'm posting this to possibly
> stimulate thought. From a generic programming perspective, could you do
> something like the following? This is pseudocode, not a particular
> language. This syntax is not designed to be put directly into a script.
> I'm just throwing this out, and haven't tested it.
>
> This assumes you can call grep from Perl, and that the line to be tested
> is in a file called lineoftext.txt . Use grep to count the matches of
> the pattern. Uses some of grep's predefined patterns per the man page.
> This assumes those patterns work for your purpose.
>
> linelength := length ( lineoftext.txt ) // get the length of the string
> if linelength > 0 // there are characters in the file
> for counter = 1 to linelength // iterate through each character in the
> string
> thischaracter := lineoftext.txt [ counter ] // extract the character at
> the "counter" position in the string
> if result ( grep -c [:alnum:] thischaracter ) == 0 // this character is
> NOT alphanumeric
> andif result ( grep -c [:punct:] thischaracter ) == 0 // this character
> is NOT punctuation
> andif result ( grep -c [:space:] thischaracter ) == 0 // this character
> is NOT a space
> andif asciivalue ( thischaracter ) <> 9 // this character is NOT a TAB
> print "character out of bounds"
> set appropriate warning flag
> endif
> endif
> endif
> endif
> next counter
> elseif linelength == 0 // there are no characters in the file
> print "there is nothing to test"
> set appropriate warning flag
> endif
Thanks for the effort, it appears I have a working solution though.
>
>
> On 02/28/2011 12:59 PM, Geoffrey Myers wrote:
>> I'll try this again as I didn't get any bites before. I'm trying to
>> come up with a perl regex that will identify a line of data that has any
>> character outside of alphanumeric, punctuation, spaces, tabs.
>>
>> Can't seem to formulate.
>>
>> anyone?
>>
>>
>
--
Until later, Geoffrey
"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson
More information about the Ale
mailing list