“Substring” Kode Jawaban

JavaScript mendapatkan 10 karakter string pertama

var str = "Hello world That is reallly neat!";
var res = str.substring(0, 5);//get first 5 chars
Grepper

JS Dapatkan 3 karakter pertama dari string

const string = "0123456789";
console.log(string.slice(0, 2)); // "01"
console.log(string.slice(0, 8)); // "01234567"
console.log(string.slice(3, 7)); // "3456"
Modern Mouse

Substring

const str = 'Mozilla';

console.log(str.substring(1, 3));
// expected output: "oz"

console.log(str.substring(2));
// expected output: "zilla"
Prickly Pony

Substring

# To find the index of a substring in another string
# Take for instance, below take two strings: str and substr. 

str="hello world"
substr="world"
 
prefix=${str%%$substr*}
index=${#prefix}
 
if [[ index -eq ${#str} ]];
then
    echo "Substring is not present in string."
else
    echo "Index of substring in string : $index"
fi

Mckynde

Substring

var str = "The MEAN stack is MongoDB, Express.js, AngularJS, and Node.js";
str.indexOf('MongoDB') !== -1 // true
str.indexOf('Java') !== -1 //false
str.indexOf('Node', 5) !== -1 //true
Nutty Nightingale

Substring

/*Delimiter variables, first and second position*/
DECLARE @dfp AS CHAR(1);
DECLARE @dsp AS CHAR(1);
DECLARE @text VARCHAR(MAX);

SET @dfp = ';';
SET @dsp = '@';
SET @text = 'I want you to ;Extract this@ substring for me please.';

SELECT SUBSTRING(@text, (CHARINDEX(@dfp, @text) + 1), (CHARINDEX(@dsp, @text) - 2) - CHARINDEX(@dfp, @text) + Len(@dsp))
Combative Cod

Jawaban yang mirip dengan “Substring”

Pertanyaan yang mirip dengan “Substring”

Lebih banyak jawaban terkait untuk “Substring” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya