Jump to content

effigy

Staff Alumni
  • Posts

    3,600
  • Joined

  • Last visited

    Never

Everything posted by effigy

  1. According to the vague docs, try this: replace [ ^(.+?)(?=accepted|wrote) ] with [ Someone ]
  2. echo preg_replace('%</?a(?(?<=<a)[^>]*)>%', '', $data);
  3. Assuming they use PCRE: <pre> <?php $data = <<<DATA # FirstName LastName accepted your friend request. # FirstName LastName wrote on your Wall. # FirstName LastName wrote on your Wall. DATA; echo preg_replace('/^(.+?)(?=accepted|wrote)/m', 'Someone ', $data); ?> </pre> You can use str_replace to exchange "your" with your name, since it should be static
  4. /^(BODY:)(.+?)(-----)/ms /m enables multi-line mode and /s allows . to match new lines.
  5. How about parsing the table into a data structure, modifying the structure, then dumping the structure back into a table format?
  6. An example of optional quotes can be found here.
  7. Your patterns are using <div class="quote">, which I do not see.
  8. See if this works for your data set: <pre> <?php $data = <<<DATA <a href="/dir/page.html">A</a> -> http://somesite.com/dir/page.html <a href="dir/page.html">B</a> -> http://somesite.com/dir/page.html <a href="http://somesite.com/dir/page/html">C</a> -> http://somesite.com/dir/page/html DATA; echo htmlspecialchars( preg_replace( '%(<a[^>]+)href="(?:http://[^/]+/|/)?([^"]+)"%', '$1href="http://dudeel.com/lProxy?p=http://somesite.com/$2', $data ) ); ?> </pre>
  9. <pre> <?php $str = '<input type="hidden" name="example" value="0bb49ad4f2276624018e2011bc6a5282">'; preg_match('/<[^>]*name="example"[^>]*value="([^"]+)/', $str, $matches); array_shift($matches); print_r($matches); ?> </pre>
  10. I was going by the OP's second post, but based on their first I see that they are looking for more specifics.
  11. Scheme, one of the main dialects of LISP, is used in lilypond--a spectacular program.
  12. /\A[A-HJ-NPR-Z\d]{11}\d{6}\z/
  13. <pre> <?php $str = '{1}{2}{3}'; $pieces = preg_split('/[{}]/', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($pieces); ?> </pre> preg_* functions use delimiters, thus the /.../. [...] is a character class which matches one character out of its pool, in this case { or }. You can find more details in my signature links.
  14. Ah, but it does: <pre> <?php $string = <<<DATA SID=DQAAAIwAAADYBzOfXMgIg-QKywsJCyPM6bbx5YVkPsZQPTyaHy16Pa6uNB4RXteTVBzTXXPkKxMNNlU4YuEe3DiKYvaQMHAgh_JbJzaT5490_WvtwJwOCepSu_R4bYFyTwJe-y7CRg3MMwpVkXtwaf-8vbznovVBbjSzRDp7kRpdWW1TXtOlDD_Vn-G1-cTHRMyA25wlypI LSID=DQAAAI4AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhADnL25OR8cuh8ZayssClsjlQh-2NenhdcQzX83Vfjvq1oxbSERlhfNGR88Hoy_DquC5KWF8saxjrvdeGVaLu-CktIDnTwtmd3Ozv_TxxXiM Auth=DQAAAI0AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhpaLcYAjO4yvGhZbl93gru4A4LtlXFRtqPNHItkoc_EyttT0-2cT81jxRjuX5qQJjmYEAYPmW4N0zYGVIJm1j84PlMdxZfuakFeEGAwjuXxE DATA; preg_match('/Auth=.*/', $string, $matches); print_r($matches); ?> </pre>
  15. /Auth = .*/ Does the text following it include the equals sign? Are there new lines in the data?
  16. The data is in UTF-8 and so is MySQL? Are you specifically telling MySQL that you're using UTF-8?
  17. You place the variables one after another: /$regex_price$regex_date.../.
  18. effigy

    regex help

    <pre> <?php $data = <<<DATA -Albania LATI -> Tirana + -Angola FNLU -> Luanda + -Antarctic NZCM -> Williams Field + -Antigua and Barbuda TAPA -> Vc Bird International Airport Antigua + -Algeria DAUA -> Adrar DABB -> Annaba DABC -> Constantine DAAG -> Dar-El-Beida DAUG -> Ghardaia DAUH -> Hassi-Messaoud DAUZ -> In Amenas DAOO -> Oran / Es Senia DAAT -> Tamanrasset / Aguenna DABS -> Tebessa DAON -> Tlemcen Zenata + -Argentina SABE -> Aeroparque Bs. As. Aerodrome SAZB -> Bahia Blanca Aerodrome SAZS -> Bariloche Aerodrome SAVC -> Comodoro Rivadavia Aerodrome SAAC -> Concordia Aerodrome SACO -> Cordoba Aerodrome SARC -> Corrientes Aero. SADD -> Don Torcuato Aerodrome SAEZ -> Ezeiza Aerodrome SARF -> Formosa Aerodrome SARI -> Iguazu Aerodrome SASJ -> Jujuy Aerodrome SAZM -> Mar Del Plata Aerodrome SAME -> Mendoza Aerodrome SAZN -> Neuquen Aerodrome SARL -> Paso De Los Libres Aerodrome SARP -> Posadas Aero. SARE -> Resistencia Aero. SAWG -> Rio Gallegos Aerodrome SAWE -> Rio Grande B. A. SAAR -> Rosario Aerodrome SASA -> Salta Aerodrome SANU -> San Juan Aerodrome SANE -> Santiago Del Estero Aero. SAAV -> Sauce Viejo Aerodrome SAVT -> Trelew Aerodrome SANT -> Tucuman Aerodrome SAOR -> Villa Reynolds Aerodrome + -Armenia UGEE -> Yerevan + -Aruba TNCA -> Queen Beatrix Airport, Aruba + -Australia YPAD -> Adelaide Airport YBAS -> Alice Springs Aerodrome YPPH -> Belmont Perth Airport YBBN -> Brisbane Airport M. O YBRM -> Broome Airport YPEA -> Bullsbrook Pearce Amo YBCS -> Cairns Airport YSCB -> Canberra YPDN -> Darwin Airport YSDU -> Dubbo YMHB -> Hobart Airport YPTN -> Katherine Aerodrome YPLM -> Learmonth Airport YMML -> Melbourne Airport YSNF -> Norfolk Island Airport YPPD -> Port Hedland Pardoo YSRI -> Richmond Aus-Afb YBRK -> Rockhampton Airport YSSY -> Sydney Airport YBTL -> Townsville Amo + -Austria LOWG -> Graz-Thalerhof-Flughafen LOWI -> Innsbruck-Flughafen LOWK -> Klagenfurt-Flughafen LOWL -> Linz / Hoersching-Flughafen LOWS -> Salzburg-Flughafen LOWW -> Wien / Schwechat-Flughafen + -Azerbaijan UBBB -> Baku / Bine Airport + -Bahamas MYGF -> Freeport, Grand Bahama MYNN -> Nassau Airport + -Bahrain OBBI -> Bahrain International Airport + -Bangladesh VGEG -> Chittagong Patenga VGZR -> Kurmitola, Dia + -Barbados TBPB -> Grantley Adams + -Belarus UMMS -> Minsk EVRA -> Riga Airport UMII -> Vitebsk + -Belgium EBAW -> Antwerpen / Deurne EBBE -> Beauvechain EBLG -> Bierset EBBT -> Brasschaat EBBR -> Bruxelles National EBCI -> Charleroi / Gosselies EBCV -> Chievres EBLB -> Elsenborn EBFS -> Florennes EBTN -> Goetsenhoven EBBL -> Kleine Brogel EBFN -> Koksijde EBOS -> Oostende Airport EBDT -> Schaffen EBSP -> Spa / La Sauveniere + -Belize MZBZ -> Belize / Phillip Goldston Intl. Airport + -Benin DBBB -> Cotonou + -Bermuda TXKF -> Bermuda + -Bolivia SLCA -> Camiri SLCN -> Charana SLCO -> Cobija SLCB -> Cochabamba SLCP -> Concepcion SLLP -> La Paz / Alto SLMG -> Magdalena SLOR -> Oruro SLPO -> Potosi SLPS -> Puerto Suarez SLRY -> Reyes SLRI -> Riberalta SLRB -> Robore SLRQ -> Rurrenabaque SLSI -> San Ignacio De Velasco SLJO -> San Joaquin SLJE -> San Jose De Chiquitos SLSA -> Santa Ana SLSU -> Sucre SLTJ -> Tarija SLTR -> Trinidad SLVM -> Villamontes SLVR -> Viru-Viru SLYA -> Yacuiba + -Botswana FBFT -> Francistown FBGZ -> Ghanzi FBJW -> Jwaneng FBKE -> Kasane FBMN -> Maun FBSK -> Seretse Khama International Airport FBSW -> Shakawe FBTS -> Tsabong FBTE -> Tshane + -Brazil SBAF -> Afonsos Aeroporto SBAT -> Alta Floresta Aeroporto SBHT -> Altamira SBAR -> Aracaju Aeroporto SBBG -> Bage Aeroporto SBBU -> Bauru SBBE -> Belem Aeroporto SBCF -> Belo Horizonte SBBH -> Belo Horizonte Aeroporto SBBV -> Boa Vista Aeropor-To SBBR -> Brasilia Aeroporto SBKG -> Campina Grande SBKP -> Campinas Aeroporto SBCG -> Campo Grande Aeroporto SBCV -> Caravelas Aeropor-To SBAA -> Conceicao Do Araguaia SBCR -> Corumba SBCY -> Cuiaba Aeroporto SBBI -> Curitiba SBCT -> Curitiba Aeroporto SBEG -> Eduardo Gomes International SBFN -> Fernando De Noronha SBFL -> Florianopolis Aeroporto SBFZ -> Fortaleza Aeropor-To SBFI -> Foz Do Iguacu Aeroporto SBGL -> Galeao SBGO -> Goiania Aeroporto SBGW -> Guaratingueta SBGR -> Guarulhos Civ / Mil SBIL -> Ilheus Aeroporto SBIZ -> Imperatriz SBIH -> Itaituba SBLO -> Londrina Aeroporto SBME -> Macae SBMQ -> Macapa SBMO -> Maceio Aeroporto SBMN -> Manaus Aeroporto SBMA -> Maraba SBMT -> Marte Civ / Mil SBNT -> Natal Aeroporto SBPK -> Pelotas SBYS -> Pirassununga SBPC -> Pocos De Caldas SBPP -> Ponta Pora Aeropor-To SBCO -> Porto Alegre SBPA -> Porto Alegre Aero-Porto SBPN -> Porto Nacional Aeroporto SBPV -> Porto Velho Aeroporto SBDN -> Presidente Prudente SBRF -> Recife Aeroporto SBJR -> Rio / Jacarepagua SBRB -> Rio Branco SBRJ -> Rio De Janeiro Aeroporto SBSV -> Salvador Aeroporto SBSC -> Santa Cruz Aeropor-To SBSM -> Santa Maria Aero-Porto SBSN -> Santarem-Aeroporto SBST -> Santos Aeroporto SBSJ -> Sao Jose Dos Campo SBSL -> Sao Luiz Aeroporto SBSP -> Sao Paulo Aeropor-To SBTT -> Tabatinga SBTF -> Tefe SBTE -> Teresina Aeroporto SBTU -> Tucurui SBUR -> Uberaba SBUG -> Uruguaiana Aeroporto SBVH -> Vilhena Aeroporto SBVT -> Vitoria Aeroporto + -British Indian Ocean Territory FJDG -> Diego Garcia + -Brunei Darussalam WBSB -> Brunei Airport + -Bulgaria LBBG -> Burgas LBPD -> Plovdiv LBSF -> Sofia Observ. LBWN -> Varna + -Burundi HBBA -> Bujumbura + -Cambodia VDPP -> Phnom-Penh / Pochentong + -Cameroon FKKD -> Douala Obs. + -Canada CYXX -> Abbotsford, B. C. CYBG -> Bagotville, Que. CYYC -> Calgary International, Alta. CYCB -> Cambridge Bay, N. W. T. CYCH -> Chatham Can-Mil CZUM -> Churchill Falls, Nfld. CYYQ -> Churchill, Man. CYOD -> Cold Lake, Alta. CYQQ -> Comox, B. C. CYZS -> Coral Harbour, N. W. T. CYEG -> Edmonton International, Alta. CYET -> Edson, Alta. CZFM -> Fort Mcpherson Airport CYFC -> Fredericton, N. B. CYQX -> Gander Int. Airport, Nfld. CYYR -> Goose, Nfld. CYZX -> Greenwood, N. S. CYHZ -> Halifax International Airport CYFB -> Iqaluit, N. W. T. CYAH -> La Grande Iv, Que. CYGL -> La Grande Riviere, Que CYZY -> Mackenzie, B. C. CYNM -> Matagami, Que. CYXH -> Medicine Hat, Alta. CYQM -> Moncton, N. B. CYUL -> Montreal / Dorval International, Que CYMX -> Montreal / Mirabel CYBU -> Nipawin, Sask. CYOC -> Old Crow Airport CYOW -> Ottawa Int'L. Ont. CYYF -> Penticton, B. C. CYZT -> Port Hardy, B. C. CYPG -> Portage Southport A CYQB -> Quebec, Que CYUY -> Rouyn Airport CWZZ -> Saglek Bay CYAY -> Saint Anthony Airport CYZV -> Sept-Iles, Que. CYAW -> Shearwater, N. S. CYUA -> Shingle Point, Y. T. CYYT -> St. John's, Nfld CYJT -> Stephenville, Nfld. CYYN -> Swift Current, Sask. CYQY -> Sydney, N. S. CYTH -> Thompson Weather Office, Man CYYZ -> Toronto Pearson Int'L. Ont. CYTR -> Trenton, Ont. CYVR -> Vancouver International Air-Port, B. C. CYYJ -> Victoria Int. Airportb. C. CYQG -> Windsor, Ont. CYWG -> Winnipeg Int. Airportman. CYZF -> Yellowknife, N. W. T. + -Cape Verde GVAC -> Sal + -Cayman Islands MWCR -> Owen Roberts Airportgrand Cayman + -Central African Republic FEFF -> Bangui + -Chad FTTJ -> Ndjamena + -Chile SCFA -> Antofagasta SCAR -> Arica SCIE -> Concepcion SCHA -> Copiapo SCDA -> Iquique / Diego Arac SCIP -> Isla De Pascua SCSE -> La Serena SCEL -> Pudahuel SCTE -> Puerto Montt SCCI -> Punta Arenas + -China ZBAA -> Beijing ZUUU -> Chengdu ZYTL -> Dalian ZGGG -> Guangzhou ZSHC -> Hangzhou ZSOF -> Hefei ZPPP -> Kunming ZGNN -> Nanning ZSSS -> Shanghai / Hongqiao ZGSZ -> Shenzhen ZBYN -> Taiyuan ZBTJ -> Tianjin / Zhangguizhu ZWWW -> Urum-Qi / Diwopu ZSAM -> Xiamen + -Christmas Island YPXM -> Christmas Island Aerodrome YPCC -> Cocos Island Airport + -Colombia SKBQ -> Barranquilla / Ernestocortissoz SKBO -> Bogota / Eldorado SKBG -> Bucaramanga / Palonegro SKCL -> Cali / Alfonso Bonillaaragon SKCG -> Cartagena / Rafael Nunez SKLT -> Leticia / Vasquez Cobo SKMD -> Medellin / Olaya Herrera SKPE -> Pereira / Matecana SKRG -> Rionegro / J. M. Cordova SKSP -> San Andres Isla / Sesquicentenario SKSM -> Santa Marta / Simon Bolivar + -Comoros FMCZ -> Dzaoudzi / Pamanzi Mayotte FMCH -> Hahaya International Airport + -Congo FCBB -> Brazzaville / Maya-Maya FCPP -> Pointe-Noire + -Cook Islands NCRG -> Rarotonga + -Costa Rica MRCH -> Chacarita MROC -> Juan Santamaria MRLB -> Liberia MRLM -> Puerto Limon MRPV -> Tobias Bolanos International + -Cote D'Ivoire DIAP -> Abidjan + -Croatia LDDU -> Dubrovnik / Cilipi LDPL -> Pula Aerodrome LDRI -> Rijeka / Omisalj LDSP -> Split / Resnik LDZD -> Zadar / Zemunik LDZA -> Zagreb / Pleso + DATA; $result = array(); $countries = preg_split('/\s*\+\s*/', $data, -1, PREG_SPLIT_NO_EMPTY); foreach ($countries as $country) { ### Retrieve name. preg_match('/^\s*-(.+)/', $country, $country_name); $country_name = trim($country_name[1]); ### Retrieve code pairs. preg_match_all('/^\s*([A-Z]+) -> (.+)/m', $country, $code_pairs); $i = 0; foreach ($code_pairs[1] as $abbrev) { $result[$country_name][$abbrev] = $code_pairs[2][$i]; ++$i; } } print_r($result); ?> </pre>
  19. effigy

    regex help

    What have you tried, or how would you start the expression?
  20. Split on comments also: /(<!--.+?-->|<[^>]*>)/.
  21. Take the required part out of the alternation: /must_match(?:optional_match|optional_match|...)/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.