{"id":1050,"date":"2017-08-28T16:55:39","date_gmt":"2017-08-28T22:55:39","guid":{"rendered":"https:\/\/emanuelpaxtian.com\/blog\/?p=1050"},"modified":"2017-08-28T16:55:39","modified_gmt":"2017-08-28T22:55:39","slug":"dejar-solo-letras-y-numeros-con-preg_replace","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/dejar-solo-letras-y-numeros-con-preg_replace\/","title":{"rendered":"Dejar solo letras y n\u00fameros con preg_replace"},"content":{"rendered":"<p>Hace poco un amigo me pregunto como dejar puras letras (mayusculas y min\u00fasculas)  y n\u00fameros en una cadena de texto eliminando todo lo que dem\u00e1s, en php existe una funci\u00f3n muy interesante llamada <a href=\"http:\/\/php.net\/manual\/es\/function.preg-replace.php\">preg_replace<\/a>, a continuaci\u00f3n le muestro una sencilla funci\u00f3n <\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction LetrasyNumeros($texto)\r\n{\r\n      $textoLimpio = preg_replace('(&#x5B;^A-Za-z0-9])', '', $texto);\t     \t\t\t\t\t\r\n      return $textoLimpio;\r\n}\r\n<\/pre>\n<p>Modo de uso <\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$texto=&quot;Este texto-Limpio&quot;\r\necho LetrasyNumeros($texto)\r\n\/\/salida\r\n\/\/EstetextoLimpio\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hace poco un amigo me pregunto como dejar puras letras (mayusculas y min\u00fasculas) y n\u00fameros en una cadena de texto eliminando todo lo que dem\u00e1s, en php existe una funci\u00f3n&hellip;<\/p>\n","protected":false},"author":1,"featured_media":642,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1050","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/1050\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/642"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}