[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [TEKNIK] Lille RegExp spørgsmål - løst



Kim Schulz wrote:

On Mon, 28 Feb 2005 00:23:28 +0100
Kim Schulz <sslug@sslug> wrote:



On Mon, 28 Feb 2005 00:06:33 +0100
Asbjorn Grandt <sslug@sslug> wrote:



Kim Schulz wrote:



On Sun, 27 Feb 2005 22:38:08 +0100
Asbjorn Grandt <sslug@sslug> wrote:





Hej

Er der en nem måde med Regexp at konvertere en streng af ord til


samme >


form som f.eks. Java metode navne :
"Dette er en test" bliver til "DetteErEnTest" ?




hvilket program/sprog vil du bruge til det?

i php kunne det se således ud:
<?php
$streng = "Dette er en test";
print implode("",array_map("ucfirst",split(" ", $streng)));
?>






Jeg skal bruge det i Java, regexp parseren er Perl5Util klassen i Apaches Jakarta Oro pakke.
Pakken er ikke perfekt, men det er den eneste jeg kender der kan
parse


regexps som "s/expr/repl/gmi..." imod en streng.

Jeg ved at en StringTokenizer er en af de mere normale måder at gøre

dette på, ma jeg tænkte at når jeg nu er igang med en masse Regexp
kald, kan jeg lige så godt fortsætte...



hmm i perl ville jeg gøre noget ala


s/\s+(.)/\u$1/g som dog ikke fanger første ord på linjen




og for at fange første tegn på linjerne også så


s/(?:\s+|^)(.)/\u$1/g

og så skulle den vist være der :-)



Det virker perfekt, tak :-)


-- Mvh A.Grandt -- C:\DOS\> C:\DOS\RUN\> RUN:\DOS\RUN\>




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:26 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *