[ale] perl regex.... again

Ron Frazier atllinuxenthinfo at c3energy.com
Tue Mar 1 00:12:26 EST 2011


The listbot butchered my indenting. Hope you guys can read this.

Ron

On 03/01/2011 12:08 AM, 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
>
>
> 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?
>>
>>
>>      
>    

-- 

(PS - If you email me and don't get a quick response, you might want to
call on the phone.  I get about 300 emails per day from alternate energy
mailing lists and such.  I don't always see new messages very quickly.)

Ron Frazier

770-205-9422 (O)   Leave a message.
linuxdude AT c3energy.com



More information about the Ale mailing list