Difference between revisions of "Remove non-letters from a string"

From CodeCodex

m (Reverted edit of 222.151.117.204, changed back to last version by Why My Fleece?)
Line 1: Line 1:
{{Infobox See Also String}}
+
[http://paga.rigour.info/ricevitore-gps/ ricevitore gps tom] [http://content.rigour.info/html/download-shanghai/ download shanghai] [http://paga.rigour.info/lu-mercatu/ lu mercatu] [http://milano.rigour.info/oltre-ogni.htm oltre ogni rischio] [http://web.rigour.info/emma-shapplin/ emma shapplin - carmine meo] [http://online.rigour.info/she-drives/ she drives me crazy] [http://dir.rigour.info/cornaredo-gp/ cornaredo gp] [http://speed.rigour.info/samuelson-libri.htm samuelson libri] [http://online.rigour.info/carta-treviso/ carta treviso] [http://uve.rigour.info/blog/www-juegos.htm www juegos] [http://gratis.rigour.info/content/view/dragostea-din.htm dragostea din tea] [http://blog.rigour.info/web/dj-aligator/ dj aligator and vspishkin davaj] [http://note.rigour.info/content/view/figlio-cognato.htm figlio cognato terzo affine] [http://load.rigour.info/view/new/whirlpool-arc.htm whirlpool arc 5551] [http://milano.rigour.info/joybook-.htm joybook 6000 benq portatili] [http://here.rigour.info/blog/produzione-abbigliamento.htm produzione abbigliamento rom] [http://blog.rigour.info/web/european-society/ european society cardiothoracic surgery] [http://guest.rigour.info/library/html/jos/ jos] [http://web.rigour.info/gesso/ gesso] [http://gratis.rigour.info/content/view/i-don.htm i don t want to miss a thing] [http://all.rigour.info/alfa/ alfa 164] [http://here.rigour.info/blog/la-giga.htm la giga brace] [http://down.rigour.info/blog/che-te.htm che te po da] [http://down.rigour.info/blog/effetti-sonori.htm effetti sonori sexy] [http://down.rigour.info/blog/galfield.htm galfield] [http://italy.rigour.info/blog/kingston.htm kingston 512 133] [http://web.rigour.info/ricette-cucina/ ricette cucina it] [http://blog.rigour.info/web/wireless-camera/ wireless camera] [http://blog.rigour.info/web/fujitsu-siemens/ fujitsu siemens scenic 320] [http://down.rigour.info/blog/enrico-paola.htm enrico paola] [http://dir.rigour.info/lg-lcd/ lg lcd 32 rz-32lz50] [http://online.rigour.info/varsavia-cose/ varsavia cose fare] [http://it.rigour.info/topic/router-dlink/ router d-link dsl-502t] [http://up.rigour.info/description/lib/quicken.htm quicken] [http://all.rigour.info/he-i/ he i believe] [http://milano.rigour.info/il-profumo.htm il profumo delle viole] [http://italy.rigour.info/blog/carillon.htm carillon] [http://here.rigour.info/blog/conversione-formato.htm conversione formato pdf doc] [http://web.rigour.info/baby-can/ baby can i hold you tonight] [http://here.rigour.info/blog/paola-e.htm paola e chiara cantanti] [http://web.rigour.info/lutero-lutero/ lutero lutero] [http://dir.rigour.info/compilation-inter/ compilation inter] [http://guest.rigour.info/library/html/kiev-apartment/ kiev apartment] [http://note.rigour.info/content/view/telecomando-wireless.htm telecomando wireless per ipod] [http://speed.rigour.info/solvente-df.htm solvente df  1 fl 100 ml] [http://online.rigour.info/massaggi-video/ massaggi video] [http://it.rigour.info/topic/de-ce/ de ce na minti] [http://it.rigour.info/topic/digitale-sat/ digitale sat] [http://up.rigour.info/description/lib/isola-dellarte.htm isola dellarte] [http://note.rigour.info/content/view/tavolo-pranzo.htm tavolo pranzo] [http://blog.rigour.info/web/confort-trio/ confort trio] [http://online.rigour.info/mp-cruzer/ mp3 cruzer] [http://down.rigour.info/blog/server-fujitsu.htm server fujitsu siemens primergy econel] [http://online.rigour.info/telescopio-usato/ telescopio usato] [http://here.rigour.info/blog/lezioni-ballo.htm lezioni ballo on line] [http://pagina.rigour.info/assicurazione-san/ assicurazione san donato milanese] [http://milano.rigour.info/motorola-e.htm motorola e1] [http://italy.rigour.info/blog/inno-haka.htm inno haka] [http://online.rigour.info/spy-the/ spy the gost] [http://gratis.rigour.info/content/view/monitor-l.htm monitor l768] [http://gratis.rigour.info/content/view/goldenberg.htm goldenberg] [http://pagina.rigour.info/brother-t/ brother t-104] [http://load.rigour.info/view/new/abortire.htm abortire] [http://gratis.rigour.info/content/view/gioghi-dei.htm gioghi dei pokemon] [http://pagina.rigour.info/testina-stampante/ testina stampante canon] [http://italy.rigour.info/blog/la-gata.htm la gata brasilera] [http://italy.rigour.info/blog/jungle-bubble.htm jungle bubble] [http://up.rigour.info/description/lib/brigitte-bui.htm brigitte bui kocsis] [http://content.rigour.info/html/divisa-marina/ divisa marina militare] [http://here.rigour.info/blog/bmw-.htm bmw 320 blu cabrio] [http://speed.rigour.info/foto-italiane.htm foto italiane] [http://blog.rigour.info/web/idrocefalia/ idrocefalia] [http://gratis.rigour.info/content/view/giubbini-uomo.htm giubbini uomo] [http://gratis.rigour.info/content/view/estee-lauder.htm estee lauder creme] [http://speed.rigour.info/download-gioco.htm download gioco computer] [http://note.rigour.info/content/view/attaccapanni-titti.htm attaccapanni titti] [http://up.rigour.info/description/lib/james-senese.htm james senese] [http://up.rigour.info/description/lib/suteki-da.htm suteki da ne] [http://paga.rigour.info/divinacommedia/ divinacommedia] [http://blog.rigour.info/web/sapphire-radeon/ sapphire radeon x850 pro] [http://dir.rigour.info/omicidio-per/ omicidio per vocazione] [http://online.rigour.info/notre-dame/ notre dame des paris] [http://note.rigour.info/content/view/jesolo-case.htm jesolo case affitto] [http://paga.rigour.info/mappe-concettuali/ mappe concettuali per geometri] [http://all.rigour.info/marcia-nuziale/ marcia nuziale mendelssohn] [http://content.rigour.info/html/jewel-lyrics/ jewel lyrics spirit] [http://blog.rigour.info/web/temi-svolti/ temi svolti pena morte] [http://pagina.rigour.info/dikom-secure/ dikom secure digital] [http://here.rigour.info/blog/foto-helene.htm foto helene swedin] [http://speed.rigour.info/midnight-invaders.htm midnight invaders] [http://it.rigour.info/topic/le-posizioni/ le posizioni dell amore] [http://uve.rigour.info/blog/puntoedu.htm puntoedu] [http://pagina.rigour.info/oooh-gem/ oooh gem boy] [http://uve.rigour.info/blog/profumo-romeo.htm profumo romeo gigli] [http://it.rigour.info/topic/la-ragazza/ la ragazza delle bolle] [http://dir.rigour.info/xbox-media/ xbox media player] [http://content.rigour.info/html/michael-lehmann/ michael lehmann] [http://uve.rigour.info/blog/scopare-biella.htm scopare biella] [http://online.rigour.info/quick-time/ quick time for windows] [http://uve.rigour.info/blog/group-sex.htm group sex] [http://milano.rigour.info/il-prigioniero.htm il prigioniero. disco 04] [http://paga.rigour.info/oralb-professional/ oral-b professional care] [http://pagina.rigour.info/noway-in/ noway in hell] [http://online.rigour.info/diario-segreto/ diario segreto da un carcere femminile] [http://it.rigour.info/topic/r-g/ r g v 22] [http://content.rigour.info/html/testi-canzoni/ testi canzoni matia bazar] [http://pagina.rigour.info/i-got/ i got five on it] [http://gratis.rigour.info/content/view/masa-que.htm masa que mas aplauda] [http://online.rigour.info/configurazione-mms/ configurazione mms philips 350] [http://it.rigour.info/topic/fax-brother/ fax brother 8070p] [http://uve.rigour.info/blog/centro-ufficio.htm centro ufficio] [http://dir.rigour.info/paese-by/ paese by nicola di bari] [http://gratis.rigour.info/content/view/definicion-de.htm definicion de coordenadas cartesianas] [http://speed.rigour.info/tu-e.htm tu e cosi sia midi] [http://dir.rigour.info/vernice/ vernice] [http://it.rigour.info/topic/internet/ internet] [http://speed.rigour.info/lo-siento.htm lo siento mp3] [http://online.rigour.info/karan-goran/ karan goran stay with me] [http://note.rigour.info/content/view/dinosaurs.htm dinosaurs] [http://load.rigour.info/view/new/la-nave.htm la nave fantasma] [http://note.rigour.info/content/view/luomo-mascherato.htm luomo mascherato contro i pirati] [http://uve.rigour.info/blog/il-primo.htm il primo king of iron fist tournament italiano] [http://it.rigour.info/topic/nuovo-amore/ nuovo amore brigitte nielsen] [http://up.rigour.info/description/lib/lasciami-sognare.htm lasciami sognare - il canto dell uomo solitario] [http://all.rigour.info/agenzia-traduzione/ agenzia traduzione bologna] [http://guest.rigour.info/library/html/software/ software 730 2006] [http://down.rigour.info/blog/torres.htm torres] [http://guest.rigour.info/library/html/gprs-cellulari/ gprs cellulari telit] [http://web.rigour.info/home-theater/ home theater wireless] [http://uve.rigour.info/blog/memory-card.htm memory card sd hp] [http://guest.rigour.info/library/html/testi-chella/ testi chella la] [http://online.rigour.info/telefax-a/ telefax a trasferimento termico] [http://up.rigour.info/description/lib/tv-plasma.htm tv plasma 42 panasonic] [http://paga.rigour.info/heat-street/ heat street] [http://it.rigour.info/topic/annuncio-donne/ annuncio donne] [http://speed.rigour.info/centri-assistenza.htm centri assistenza omnitel] [http://down.rigour.info/blog/coniglio-non.htm coniglio, non scappare] [http://guest.rigour.info/library/html/il-treno/ il treno ha fischiato di pirandello] [http://down.rigour.info/blog/decoder-e.htm decoder e satellite] [http://load.rigour.info/view/new/sfondo-cascata.htm sfondo cascata] [http://milano.rigour.info/vmpeg.htm vmpeg] [http://up.rigour.info/description/lib/monitor-lcd.htm monitor lcd samsung 730bf] [http://up.rigour.info/description/lib/digitale-decoder.htm digitale decoder dreambox] [http://gratis.rigour.info/content/view/i-gemelli.htm i gemelli cramp] [http://gratis.rigour.info/content/view/marco-miglia.htm marco miglia] [http://pagina.rigour.info/battista/ battista] [http://speed.rigour.info/lg-rh.htm lg rh-7800 160 gb dvd- divx] [http://blog.rigour.info/web/in-mezzo/ in mezzo scorre] [http://blog.rigour.info/web/io-troia/ io troia chatta con me e daniela] [http://web.rigour.info/musulman/ musulman] [http://web.rigour.info/eva-ferrari/ eva ferrari] [http://italy.rigour.info/blog/estreme.htm estreme] [http://here.rigour.info/blog/barra-per.htm barra per porta] [http://load.rigour.info/view/new/sli-platinum.htm sli platinum] [http://guest.rigour.info/library/html/giusto-pio/ giusto pio giardino segreto mp3] [http://down.rigour.info/blog/letture-divina.htm letture divina commedia] [http://milano.rigour.info/advanced-crc.htm advanced crc utility 1.1.0] [http://dir.rigour.info/www-lapecoranera/ www lapecoranera it] [http://it.rigour.info/topic/dusty-springfield/ dusty springfield son of a preacher man] [http://paga.rigour.info/opel-corsa/ opel corsa 1.4 swing] [http://here.rigour.info/blog/labar-srl.htm labar srl] [http://italy.rigour.info/blog/morpheus.htm morpheus] [http://all.rigour.info/elicotteri/ elicotteri] [http://pagina.rigour.info/if-god/ if god will send his angels] [http://blog.rigour.info/web/pixma-ipr/ pixma ip4000r] [http://speed.rigour.info/circoncisione.htm circoncisione] [http://note.rigour.info/content/view/pelle-moda.htm pelle moda] [http://pagina.rigour.info/nikon-coolpix/ nikon coolpix 7900 nital] [http://online.rigour.info/televisioni-lcd/ televisioni lcd sony] [http://blog.rigour.info/web/disco-di/ disco di avvio xp] [http://speed.rigour.info/cuffia-plantronics.htm cuffia plantronics audio 30] [http://uve.rigour.info/blog/magic-cd.htm magic cd dvd burner] [http://gratis.rigour.info/content/view/ventole-intel.htm ventole intel amd] [http://content.rigour.info/html/saeco-professionale/ saeco professionale] [http://online.rigour.info/patria-podesta/ patria podesta] [http://dir.rigour.info/hp-workstation/ hp workstation] [http://web.rigour.info/babyliss/ babyliss 8310] [http://italy.rigour.info/blog/jeffbuckley.htm jeffbuckley] [http://paga.rigour.info/linsey-dawn/ linsey dawn mckenzie] [http://blog.rigour.info/web/attrezzi-accessori/ attrezzi accessori auto e moto] [http://dir.rigour.info/sigle-di/ sigle di telefilm] [http://uve.rigour.info/blog/lacie-ek.htm lacie 300750ek] [http://italy.rigour.info/blog/letras.htm letras] [http://dir.rigour.info/biglietto-aereo/ biglietto aereo lamezia-roma] [http://blog.rigour.info/web/venditore-tecnico/ venditore tecnico - brindisi (regione puglia - brindisi provincia)] [http://it.rigour.info/topic/major-tom/ major tom] [http://italy.rigour.info/blog/encarta-enciclopedia.htm encarta enciclopedia] [http://all.rigour.info/gioco-golf/ gioco golf minigolf] [http://web.rigour.info/konica-minolta/ konica minolta dimage xg] [http://blog.rigour.info/web/frasi-auguri/ frasi auguri 50 anni matrimonio] [http://gratis.rigour.info/content/view/uccelli-di.htm uccelli di rovo] [http://here.rigour.info/blog/nike-auricolari.htm nike auricolari] [http://pagina.rigour.info/fleuve-regione/ fleuve, regione-] [http://italy.rigour.info/blog/ferrari-immagini.htm ferrari immagini] [http://blog.rigour.info/web/gianni-danny/ gianni danny] [http://here.rigour.info/blog/vado-al.htm vado al massimo] [http://up.rigour.info/description/lib/love-erotic.htm love erotic love] [http://web.rigour.info/libero-mappa/ libero mappa] [http://all.rigour.info/max-trio/ max trio cordless] [http://here.rigour.info/blog/legend.htm legend] {{Infobox See Also String}}
 
==Implementations==
 
==Implementations==
 
===Java===
 
===Java===
 
This code removes common symbols and numbers from a string, returning letters only.  (Note, not all symbols are included.)
 
This code removes common symbols and numbers from a string, returning letters only.  (Note, not all symbols are included.)
 
  static String lettersOnly(String s) {
 
  static String lettersOnly(String s) {
     return s.replaceAll("[0-9]|[ !@#\\$%\\^&\\*\\(\\)_\\+\\-={}\\|:\"<>\\?\\-=\\[\\];',\\./`~'£€¥]","");
+
     return s.replaceAll("[0-9]|[ !@#\\$%\\^
}
+
 
+
===OCaml===
+
# let remove_nonalpha = Str.global_replace (Str.regexp "[^a-zA-Z]+") "";;
+
val remove_nonalpha : string -> string = <fun>
+
For example:
+
# remove_nonalpha "133t H4x0r";;
+
- : string = "tHxr"
+
 
+
===Perl===
+
<HIGHLIGHTSYNTAX language="perl">
+
s{[\W\d_]}{}g; # remove all non-word characters and digits and underscores
+
</HIGHLIGHTSYNTAX>
+
 
+
===Python===
+
<pre>
+
from string import letters
+
s = "hello world! how are you? 0"
+
 
+
# Short version
+
print filter(lambda c: c in letters, s)
+
 
+
# Faster version for long ASCII strings:
+
id_tab = "".join(map(chr, xrange(256)))
+
tostrip = "".join(c for c in id_tab if c not in letters)
+
print s.translate(id_tab, tostrip)
+
</pre>
+
 
+
=== Tcl ===
+
proc remove_non_ascii_letters s {regsub -all {[^a-zA-Z]} $s ""}
+
 
+
remove_non_ascii_letters "hello world! how are you? 0é" ;# -> helloworldhowareyou
+
 
+
[[Category:Java]]
+
[[Category:OCaml]]
+
[[Category:Perl]]
+
[[Category:Python]]
+
[[Category:Tcl]]
+
[[Category:String]]
+

Revision as of 00:01, 22 August 2007

ricevitore gps tom download shanghai lu mercatu oltre ogni rischio emma shapplin - carmine meo she drives me crazy cornaredo gp samuelson libri carta treviso www juegos dragostea din tea dj aligator and vspishkin davaj figlio cognato terzo affine whirlpool arc 5551 joybook 6000 benq portatili produzione abbigliamento rom european society cardiothoracic surgery jos gesso i don t want to miss a thing alfa 164 la giga brace che te po da effetti sonori sexy galfield kingston 512 133 ricette cucina it wireless camera fujitsu siemens scenic 320 enrico paola lg lcd 32 rz-32lz50 varsavia cose fare router d-link dsl-502t quicken he i believe il profumo delle viole carillon conversione formato pdf doc baby can i hold you tonight paola e chiara cantanti lutero lutero compilation inter kiev apartment telecomando wireless per ipod solvente df 1 fl 100 ml massaggi video de ce na minti digitale sat isola dellarte tavolo pranzo confort trio mp3 cruzer server fujitsu siemens primergy econel telescopio usato lezioni ballo on line assicurazione san donato milanese motorola e1 inno haka spy the gost monitor l768 goldenberg brother t-104 abortire gioghi dei pokemon testina stampante canon la gata brasilera jungle bubble brigitte bui kocsis divisa marina militare bmw 320 blu cabrio foto italiane idrocefalia giubbini uomo estee lauder creme download gioco computer attaccapanni titti james senese suteki da ne divinacommedia sapphire radeon x850 pro omicidio per vocazione notre dame des paris jesolo case affitto mappe concettuali per geometri marcia nuziale mendelssohn jewel lyrics spirit temi svolti pena morte dikom secure digital foto helene swedin midnight invaders le posizioni dell amore puntoedu oooh gem boy profumo romeo gigli la ragazza delle bolle xbox media player michael lehmann scopare biella quick time for windows group sex il prigioniero. disco 04 oral-b professional care noway in hell diario segreto da un carcere femminile r g v 22 testi canzoni matia bazar i got five on it masa que mas aplauda configurazione mms philips 350 fax brother 8070p centro ufficio paese by nicola di bari definicion de coordenadas cartesianas tu e cosi sia midi vernice internet lo siento mp3 karan goran stay with me dinosaurs la nave fantasma luomo mascherato contro i pirati il primo king of iron fist tournament italiano nuovo amore brigitte nielsen lasciami sognare - il canto dell uomo solitario agenzia traduzione bologna software 730 2006 torres gprs cellulari telit home theater wireless memory card sd hp testi chella la telefax a trasferimento termico tv plasma 42 panasonic heat street annuncio donne centri assistenza omnitel coniglio, non scappare il treno ha fischiato di pirandello decoder e satellite sfondo cascata vmpeg monitor lcd samsung 730bf digitale decoder dreambox i gemelli cramp marco miglia battista lg rh-7800 160 gb dvd- divx in mezzo scorre io troia chatta con me e daniela musulman eva ferrari estreme barra per porta sli platinum giusto pio giardino segreto mp3 letture divina commedia advanced crc utility 1.1.0 www lapecoranera it dusty springfield son of a preacher man opel corsa 1.4 swing labar srl morpheus elicotteri if god will send his angels pixma ip4000r circoncisione pelle moda nikon coolpix 7900 nital televisioni lcd sony disco di avvio xp cuffia plantronics audio 30 magic cd dvd burner ventole intel amd saeco professionale patria podesta hp workstation babyliss 8310 jeffbuckley linsey dawn mckenzie attrezzi accessori auto e moto sigle di telefilm lacie 300750ek letras biglietto aereo lamezia-roma venditore tecnico - brindisi (regione puglia - brindisi provincia) major tom encarta enciclopedia gioco golf minigolf konica minolta dimage xg frasi auguri 50 anni matrimonio uccelli di rovo nike auricolari fleuve, regione- ferrari immagini gianni danny vado al massimo love erotic love libero mappa max trio cordless legend

Related content:

Implementations

Java

This code removes common symbols and numbers from a string, returning letters only. (Note, not all symbols are included.)

static String lettersOnly(String s) {
   return s.replaceAll("[0-9]|[ !@#\\$%\\^