[Newbies] Lookaround Regex to manipulate Strings
Cédrick Béler
cdrick65 at gmail.com
Thu Jan 14 01:00:03 UTC 2010
>
>
> I have a fileName and I want to cut off its file extension (.jpg, .png
> etc.). To do this efficiently I wanted to use regular expressions with
> lookaround.
>
> So let's assume the following:
>
> | fileName |
> fileName := 'test.jpg'.
>
> fileName matchesRegex: '.+(=?.(jpg|jpeg|png))'
>
> I thought there is a possibility of returning the string without file
> extension through lookaround.
>
> Do you have any hints for me?
>
#sansPeriodSuffix can help
or if you want only some extension:
fileName regex: '.+(=?.(jpg|jpeg|png))' matchesDo: [:fname | newFileName:=
fname sansPeriodSuffix]
you probably can do it only with regex but I don't know right now :)
hth,
>
> Thanks guys!
>
> Regards,
> Hans
> ______________________________________________________
> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://movieflat.web.de
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
--
Cédrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100114/1519d839/attachment.htm
More information about the Beginners
mailing list