Skip to content
Advertisement

Tag: replace

Replace a specific character from a string with HTML tags

Having a text input, if there is a specific character it must convert it to a tag. For example, the special character is *, the text between 2 special characters must appear in italic. For example: must be converted to: So I’ve tried like: it is replacing the star character with <i> but doesn’t work if there are more special

Regex to select words with spaces for subsititution

I have string in JS which where I need to add ‘ to the values. Example: task: task one, client: Mr jhon will be converted to task:’task one’, client: ‘Mr Jhon’ Think of these string as user entered search query. This is then sent to the backed for the searching. The values need to be enclosed in ‘ Complexities taskname:

remove last directory in URL

I am trying to remove the last directory part of an URL. My URL looks like this: https://my_ip_address:port/site.php?path=/path/to/my/folder. When clicking on a button, I want to change this to https://my_ip_address:port/site.php?path=/path/to/my. (Remove the last part). I already tried window.location.replace(//[A-Za-z0-9%]+$/, “”), which results in https://my_ip_address:port/undefined. What Regex should I use to do this? Answer Explanation: Explode by “/”, remove the last element

Advertisement