Ho la stringa "{Street Name}, {City}, {Country}" e voglio rimuovere tutte le parentesi. Il risultato dovrebbe essere "Via nome, città, contea". Come lo faccio?JavaScript Remove Braces
5
A
risposta
26
Se si desidera rimuovere tutte le occorrenze di {
e }
anche se non sono abbinate le coppie, si può fare in questo modo:
var str = "{Street Name}, {City}, {Country}";
str = str.replace(/[{}]/g, "");
0
Il carattere di classe [{}]
troverà tutte le parentesi graffe
var address = "{Street Name}, {City}, {Country}";
address = address.replace(/[{}]/g, '');
console.log(address) // Street Name, City, Country
0
str = str.replace(/[{}]/g,"");
0
Utilizzare questo semplice codice javascript nella rispettiva funzione per rimuovere le parentesi graffe:
var str = '{Street Name}, {City}, {Country}';
str = str.replace(/{/g, '').replace(/}/g, '');
Problemi correlati
- 1. remove key press delay in javascript
- 2. Threadlocal remove?
- 3. JavaScript remove ZERO WIDTH SPACE (unicode 8203) dalla stringa
- 4. È prudente ignorare l'avviso "-Smissing-braces" di gcc/clang?
- 5. Python timedelta remove microseconds
- 6. htmlpurifier remove inline css
- 7. JQuery Remove() non funziona
- 8. JSoup Remove Elements
- 9. Remove Single Metaclass Method
- 10. Lista Iterator Remove()
- 11. Retrofit2 proguard remove param
- 12. MySQL Remove Trailing Zero
- 13. AngularJS remove attributes
- 14. Yii2 remove index.php dall'URL
- 15. jquery aggiungi remove class
- 16. avvertimento banca dati remove
- 17. remove css hover style
- 18. remove Default in migration?
- 19. operatore == e list :: remove()
- 20. Jquery - Remove() after hide()
- 21. remove ColorFilter/undo setColorFilter
- 22. LiveValidation .remove non funziona
- 23. XPATH remove attribute
- 24. Git remove history commegna
- 25. jQuery remove() callback?
- 26. Laravel 5.1 remove controller
- 27. Metodi EntityCollection Clear() e Remove()
- 28. Lodash remove from string array
- 29. Perché Iterator definisce l'operazione remove()?
- 30. backbone remove view cancella el