naprej
  • css
  • firefox
  • html
  • javascript
  • mootools
  • mysql
  • php
  • web
  • xubuntu
17/01/2012

JavaScript Replace first character of string

JavaScript Replace first character of string

The indexOf() method returns the position of the first occurrence of a specified value in a string.This method returns -1 if the value to search for never occurs.

var string = '|0|0|0|0';
str.indexOf( '|' ) == 0 ? str = str.replace( '|', '' ) : str;

Related Posts

Javascript Shorthand If Else, JavaScript Methods Available in the Array Object,Regular expression, new RegExp - Javascript

javascript
  • Copyright © 2009 - 2022 naprej.com