अंतर्निहित विधियों का उपयोग करके स्ट्रिंग की जाँच करें
JavaScript
xxxxxxxxxx
function checkString(str) {
if(str.startsWith('S') && str.endsWith('G')) {
console.log('The string starts with S and ends with G');
}
else if(str.startsWith('S')) {
console.log('The string starts with S but does not end with G');
}
else if(str.endsWith('G')) {
console.log('The string starts does not with S but end with G');
}
else {
console.log('The string does not start with S and does not end with G');
}
}
let string = prompt('Enter a string: ');
checkString(string);
Enter a string: String The string starts with S but does not end with G
Regex का उपयोग करके स्ट्रिंग की जाँच करें
JavaScript
xxxxxxxxxx
function checkString(str) {
if( /^S/i.test(str) && /G$/i.test(str)) {
console.log('The string starts with S and ends with G');
}
else if(/^S/i.test(str)) {
console.log('The string starts with S but does not ends with G');
}
else if(/G$/i.test(str)) {
console.log('The string starts does not with S but ends with G');
}
else {
console.log('The string does not start with S and does not end with G');
}
}
for (let i = 0; i < 3; i++) {
const string = prompt('Enter a string: ');
checkString(string);
}
Enter a string: String The string starts with S and ends with G Enter a string: string The string starts with S and ends with G Enter a string: JavaScript The string does not start with S and does not end with G
Linux - anc-api-tools कैसे स्थापित करें
Linux - curvedns कैसे स्थापित करें
Linux - zenmap कैसे स्थापित करें
Python - जाँच करें कि कोई संख्या धनात्मक है, ऋणात्मक है या 0
C - एक पूर्णांक में अंकों की संख्या की गणना करें
C - डायनामिक मेमोरी आवंटन का उपयोग करके सबसे बड़ी संख्या पाएं
Python - एक्सेल (XLSX) फाइलें लिखना
C++ - जांचें कि कोई संख्या प्रधान है या नहीं
Kotlin - एक नंबर उलटें
Kotlin - किसी संख्या का भाज्य ज्ञात कीजिए
Linux - zstd कैसे स्थापित करें
C++ - भागफल और शेष खोजें
Linux - xbitmaps कैसे स्थापित करें
Python - बबल शॅाट
C++ - लीप ईयर चेक करें
Java - एक नंबर उलटें
Kotlin - किसी संख्या को n दशमलव स्थानों पर पूर्णांकित करें
Linux - zita-ajbridge कैसे स्थापित करें
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month