Похожие чаты

Hi Can someone help me to convert this c# to js

?

string ul = "https://example.com/pinterest";
ul = ul.Replace("https://","");
ul = ul.Replace("http://", "");
ul = ul.Replace("www.", "");


var reg = Regex.Matches(ul, "(.*)/pin");
if (reg[0].Groups[1].Value.ToString().Contains("pinterest")) {
MessageBox.Show("ok");
}

5 ответов

4 просмотра

https://stackoverflow.com/help/how-to-ask

let ul = "https://example.com/pinterest"; ul = ul.replace("https://","").replace("http://", "").replace("www.", ""); if(ul.match("(.*)/pin")[0].includes("pinterest")){ console.log("ok") }

In JS the replace method can take regular expression, so you can shorten your ul.replace stuff to something like ul.replace(/^(.+\/)?(www\.)?/, "") to get it all done in one fell swoop

Kazem- Автор вопроса
J : Vaccinated 🇨🇦
In JS the replace method can take regular expressi...

yes but I couldn't make the regex I need I want this *pinterest.*/pin/* which * may be different the first * between http:// and https:// with or without www.

Похожие вопросы

Обсуждают сегодня

А чем вам питонисты не угодили?😂
.
79
or any website to buy prepaid card with xmr that's not trocador that's down?
Umbrella Party Partner
18
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Hi, I can't understand promises in JavaScript and what we should use them for (maybe the teacher didn't teach well XD). Do you have a solution for this? And are promises used...
A
29
Ещё такой вопрос. Мне необходимо хранить пароль пользователя локально. Для этого планирую использовать ini файл. Это для автозаполнения полей логин и пароль при авторизации. Е...
Евгений
19
всем доброго времени суток! имею вопрос: как понять ТОЧНО, что на нексус производится атака или он перегружен? исходные данные: - Nexus OSS 3.67.1-01 на OrientDB - Total co...
Michael Kostelcev
3
Ты просто гитлеровскую эстетику плохо понимаешь. Он же всё под Цезаря делал. А это как бы запрещённый приём в политике. Пиджаки они зачем все носят? Чтобы показать что они тип...
Ivan Kropotkin
4
Xem delist ho rha hai agr naa bhechu toh kya hoga after 1 july?
ABHI
27
i need usdt exchanged to xmr without kyc any site there ?
Certained
12
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
Карта сайта