Is is possible to strip out some legacy <br> tags and replace them with </p><p>? A line break after the closing para would also be nice. And, can I target the asterisk and following space (see below) and delete it?
I've had a look at jQuery and managed to replace the br with p tags but they're the wrong way round i.e. open then close as it just manipulates the DOM not my string.
The current code/text is supplied from a database I don't have access to and the client doesn't have the time (nor the inclination I would suspect) to amend it.
<script type="text/javascript"> var str="Welcome to Microsoft! Microsoft Microsoft"; var stringToBeFound = 'Microsoft' var ReplaceString = 'site' document.write(str.replace(stringToBeFound , ReplaceString )); </script>
My problem is im trying to use string.replace that is not case sensitive and replace every string found. I could use regular expression with it but my stringToBeFound is a dynamic variable im getting it from my database
i am trying to make an online graphing calculator with javascript. dont ask how because i dont know. but there is an annoying error in a do...while loop. although it should break out of the loop when the |'s (absolute value signs) are replaced with Math.abs( and ). here is the code.
I ran into a problem that I could not fix myself, I am trying to replace a string with another string, the replace lines look like this:
Code: var word = document.getElementById("word").innerHTML; document.getElementById("word").innerHTML = wordd.replace(/B/g, '<span class="style106">B</span><span class="style107"> </span>'); It works just perfectly if left alone, but I need to replace every letter inside this string, adding those style and span tags around each and every letter. So if I add another line to this code, like this:
I'm looking for a very simple script to replace one div with another. I've found a few but they seem overly complicated with features I don't need. I simply want to be able to click on a div and for it to be replaced with another div previously hidden.
I've got a simple navigation system set up in a framed site: navigation/top frame and a main body frame. Whenever you click on a navigation button it passes the new location to this function:
In IE the page changes to Ƈ.7.htm'. In FF (and MZ) the page "flashes" but doesn't change. If I uncomment the alert the page changes. If I put the link in the nav frame the page changes in FF.
I see the use of Javascript replace all over the web. What are all the character sequences? (sorry I am a bit of a newbie at this).
i.value.replace(/[^d]+/g, '');
I understand that /g is global and /i is case sensitive, but what are the rest? I am asking because I am trying to write a function that takes an input and replaces everything but numbers and a . (for decimal numbers).
I am creating a "Please wait..." page to show a friendly message to my site users while the data is being loaded. I am using location.replace() javascript function to do this.
The problem that I am facing is displaying the records that the application has already processed on the wait page. Does anybody know what can I do to pass data field value from the end page where the data processing is going in background on to the wait page.
I found this in one of my old scripts but I can't remember what the -0 was used for. I remember it was a shortcut method but I can't remember for what. Does this ring a bell with anyone?
var Pattern = /px/; var T = paddingArry[0].replace(Pattern, "")-0;
What I want to do is add an onclick event handler to row1 to insert a row after row1. I can't seem to find a way to do it though. After creating the new row node, I could try something like document.getElementById("row1").parentNode.appendChild(newNode) but that would add the new row to the bottom of the table. The insertBefore() method is the right idea but I want to insert the new row AFTER row1 and there doesn't seem to be an insertAfter() method.
I thought about navigating through the DOM tree to get the row after row1 and then using insertBefore() but the table is generated dynamically and there won't necessarily be a next row.
I was tring to write a function to make that took the letters that a user is searching for and making the first occurrence of it bold in the results (ignoring the case).
>From reading javascript books and looking at posts in this group, I
thought this would work. Perhaps I misunderstood what $1 is. But in the results, I am getting a bold $1 with IE6.
How can I determine what the occurrence of the phrase is in the correct case?
I realize I can write this parsing the string without regular expressions but I thought this would be cleaner.
var match = new RegExp( escapeCharsForRegExp(typedLetters), "i"); if (match.test(text)) { text = text.replace(match, '<b>' + '$1' + '</b>' ); }
I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I supposed to write this function?
String.replace(/</g,'<');
2)
While I'm on the subject, anyone know why they implemented replace using a slash delimiter instead of quotes? I know it's how it's done in Perl but why is it done that way?
3)
One last regexp question: is it possible to do something like this: String.replace(/<(.*?)>(.*?)</$1>/ig,'<$1>$2</$1>'); This is just an example where a sub-match used in a regular expression must sub-match again exactly as it did the first time later in the same string. But I don't know how to do that in a regexp although it seems like it should be possible.
Basically the php gives the javascript a list of movies located in my directory, I am able to successfully launch any movie not containing a "space." I changed the code a little bit to allow for a "text input" and manually typed the name of a movie with %20 instead of a space and it worked. So I would like to modify the above code to do this automatically without visibly changing the movie titles. I am not sure where I should change the code.
I'm trying to write a script to grab the current URL if on the desired site (using Greasemonkey, a Firefox extension) and replace a variable inside the URL (example: site.com/file.php?a=a&b=target&c=c) with the variable embed inside my script.
Can anyone lead me in the write direction, or know a similar script which I could study from and sculpture the concept?
I'm trying to create a text-only version of one of my sites. I have a toggle link switching between text and full html versions. If text-only was selected, then it changes the stylesheet.However, I need to be able to replace all <img> tags with their associated alt attributes to make it completely text-only.
I want to replace a string after checking it is valid by passing the values to a function.
The string is '<img width="300" height="300">'
Code: var text = '<img width=300 height=300>' text = text.replace(/<img width=(.*?) height=(.*?)>/gi, check_img($1, $2)); The $1 and $2 values are not being passed to the function. This same method works in PHP by the e Modifier but not in JS.
I need to open a new window(child) once the user clicks on the KPI(parent window) field on a Web page. I pass some parameters in the string. Problem is the KPI field can have the "&" ampersand character in it and the string thinks it is another parameter being sent. how I can get around this?
I have a script that insert <br> tag when user press ENTER.But my paragraphs are all in the same line (on the textarea). How could I turn the last thing on the phrase and the other phrase starts on the line above???for example:hello there<br>how are you?here is the script:textarea id="t" rows="22" cols="80">
I want to write a reg exp that replaces strings matching "A anystring" or "An anystring" or "The anystring" with "anystring", basically removing the articles at the beginning of the strings. I got as far as this: