Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Saturday 23 June 2018

Remove special characters from string php

$title = 'Apple Fritter E Juice 120ml By Loaded E Liquid';
$urltitle = str_replace(' ', '-', $title);
$urlkey = preg_replace("/[^a-zA-Z0-9]+/[^a-zA-Z0-9]+/", "", strtolower($urltitle));
echo $urlkey;

Friday 13 May 2016

How to replace string with regex in jQuery Javascript in Html with Using nodeType / node Shortcode


How to replace string with regex in jQuery Javascript in Html with Using nodeType / node

Text

[jems-countdown token="4" data-id="20136582"]

Script

jQuery(document).ready(function(){
   
    $('body *').contents().each(function() {
        if(this.nodeType == 3) {
            var u = this.nodeValue;
            var reg = /\[(jems-countdown.*)\]/g;
            $(this).replaceWith(u.replace(reg,'<div class="metcounter" $1>kanasagra</div>'));
        }
    });
  });