On Wed, 24 Aug 2011 20:24:00 +0530, Ramprasad Prasad wrote:
> Assume I have to find the first unique character in a string
>
> $string = "abtable";
>
> # t is the first unique string
>
> I tried using a negative backtrace lookup to get the answer in a single
> regex ... But something is missing
Hi Prasad,
>>still does not work
>>$_ = "zzabtable";
>>/(.)(?!.*\1)/ && print "$1\n";
>>Output is z
The script above worked just has it was intended. The output should be 'z'
and not 't' as you suppose. Your code will match the first unique string
that is not repeated, after other letters. And in
still does not work
$_ = "zzabtable";
/(.)(?!.*\1)/ && print "$1\n";
Output is z
On 8/24/11, Chris Charley wrote:
>>Assume I have to find the first unique character in a string
>>
>>$string = "abtable";
>>
>># t is the first unique string
>>
>>I tried using a negative backtrace lookup to get the
Assume I have to find the first unique character in a string
$string = "abtable";
# t is the first unique string
I tried using a negative backtrace lookup to get the answer in a
single regex ... But something is missing.
/(.).(?!\1)/ && print $1;
it seems fine ... But doesn't work
--
Sent fr
On 24/08/2011 15:54, Ramprasad Prasad wrote:
Assume I have to find the first unique character in a string
$string = "abtable";
# t is the first unique string
I tried using a negative backtrace lookup to get the answer in a
single regex ... But something is missing.
/(.).(?!\1)/&& print $1;
Hi Ram,
On Wed, 24 Aug 2011 20:24:00 +0530
Ramprasad Prasad wrote:
> Assume I have to find the first unique character in a string
>
In that case, use a hash. Is there any reason you want to do it using a regex?
Regards,
Shlomi Fish
> $string = "abtable";
>
> # t is the first uniqu
Assume I have to find the first unique character in a string
$string = "abtable";
# t is the first unique string
I tried using a negative backtrace lookup to get the answer in a
single regex ... But something is missing.
/(.).(?!\1)/ && print $1;
it seems fine ... But doesn't work
--
Sent fr