Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z .replace
ELEFANTE
post 16.04.2021, 08:29:02
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 12.04.2021

Ostrzeżenie: (0%)
-----


Witam, czy mógłby mi ktoś dlaczego znak "[" nie jest zastępowany przez spację

argument[2] wygląda tak "test[123[321";
  1. var x = 0;
  2. for (x = 0; x < argument[2].length; x++) {
  3. if(argument[2][x] == "[")
  4. {
  5. argument[2][x] = argument[2][x].replace('[',' ');
  6. console.log(argument[2][x]);
  7. }
  8.  
  9. }


Ten post edytował ELEFANTE 16.04.2021, 08:29:59
Go to the top of the page
+Quote Post
trueblue
post 16.04.2021, 08:57:01
Post #2





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


A po co takie kombinacje?

  1. let a = "test[123[321";
  2. a = a.replace(/\[/g, ' ');


--------------------
Go to the top of the page
+Quote Post
ELEFANTE
post 16.04.2021, 12:18:57
Post #3





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 12.04.2021

Ostrzeżenie: (0%)
-----


Cytat(trueblue @ 16.04.2020, 09:57:01 ) *
A po co takie kombinacje?

  1. let a = "test[123[321";
  2. a = a.replace(/\[/g, ' ');

Dzięki wielkie działa

Ten post edytował ELEFANTE 16.04.2021, 12:19:13
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 16:00