newbie question

torjon_at_NOSPAMnterport.net
Date: 08/14/04


Date: Fri, 13 Aug 2004 22:34:42 GMT

I need to divide a series of fields, abcd, into single fields.

I thought of using the pattern .{1}.{1}.{1}.{1} etc but what this
returns is:
$1 = abcdfg
$2=a
$3=b
$4=c.

Now I can work around this, just slipping $1, but I need to know how
to make a regexp that will do this. Doesn't perl view the above
regexp and say I need 1 single character 5 times, then work its way
throughthe fields?

Also, when a pattern matches in a reg exp it is stored in a variable
$1. If a regexp has three matches it is stored in $1, $2 ,$3. I need
to find the number of matches, the length of this array in order to
iterate through it, or at least I need the name of the array so i can
do a foreach..

Thanks!



Relevant Pages

  • Re: Bug in Strings split method???
    ... The limit parameter controls the number of times the pattern is ... applied and therefore affects the length of the resulting array. ... limit n is greater than zero then the pattern will be applied at most n ...
    (comp.lang.java.programmer)
  • Re: Surprise in array concatenation
    ... >> computational states for which A is considered be 1. ... >> memory dump and discover a bit pattern 000000001 at the address FF07712CA0 ... could you stop naming this ADT an array? ... > These are Ada arrays, rock solid low level stuff, based on preexisting ...
    (comp.lang.ada)
  • How to improve performance of regular expression pattern matching
    ... a specific pattern on each line. ... so for each line of the input file the script needs to loop ... through the array until it has either found a pattern stored in the ... I first used the following code to compare the line with the array ...
    (comp.unix.shell)
  • Re: Regular expression, (preg_split etc...), some help please.
    ... Because that pattern doesn't allow letters outside quoted strings. ... The first array contains all the data, ...
    (comp.lang.php)
  • Re: Checking if a list of names appears in a body of text.
    ... an array intersection, but this is problematic for two-word company ... Let's suppose that we aren't interested in where the phrase occurs, or whether it occurs several times, but just whether or not it appears at all. ... So our approach will be to take the original phrase, turn it into a pattern, match the pattern, and return true if the pattern has been matched: ... String strPattern = MakePattern; ...
    (microsoft.public.dotnet.languages.csharp)