replace

Converting HTML to its safe entities with Javascript

I'm trying to convert characters like < and > into &lt; and &gt; etc. User input is taken from a text box, and then copied into a DIV called changer. here's my code: function updateChanger() { var message = document.getElementById('like').value; message = convertHTML(message); document.getElementById('changer').innerHTML =...

pre_replace multi-dimensional array problem

I want to replace word groups by links. I use a multi-dimensional array to define these (in the real world there will be thousands of them). Here's the code: $text = "<html><body><pre> Here is Foo in text. Now come Baz? and Bar-X. Replace nothing here: Foo (followed by brackets). </pre></body></html>"; $s = array( array("t" => "...

jQuery find and replace text in a variable

Hello, I have a variable like var theUrl = 'http://www.google.com/?q=%s'; then i have a input box like <input type="text" id="searchBox" value="" /> and a button like <input type="button" id="searchButton" value="Search" /> when the button is clicked, i should get a alert where the %s of the var theUrl should be replaced with t...

How to replace the blank

Given the code: import clr clr.AddReference('System') from System.Text.RegularExpressions import * def ReplaceBlank(st): return Regex.Replace( st,r'[^a-z\s](\s+)[^a-z\s]', lambda s:s.Value.Replace(' ', ''),RegexOptions.IgnoreCase) I expect the input ABC EDF to return ABCDEF but it doesn't work, what did I do wron...

jQuery: Generate valid tag of string

Hey, I am looking for a way to generate a valid tag (string with only a-z and minus as valid chars) out of a given string. Just let me show you the code: <p> <label>Tag Title *:</label> <input type="text" class="tag_title" name="input_tag_title" value="" /> </p> <p> <label>Tag (A-Z; -) *:</label> <input type="text" cla...

Replace CR with CRLF in a Textfield

Hello, i got some problem with replacing a CarriageReturn (CR) to a CarriageReturn LineFeed (CRLF) entry´s in a textfield on MS SQL 2005 System. There´s a table "notice" where a textfield "desc" is filled with some content which contains some CR. So some example is: Mister Smith "CR" Road 123 "CR" Germany I try to replace the CR with...

Replace names in text with links

I want to replace names in a text with a link to there profile. $text = "text with names in it (John) and Jacob."; $namesArray("John", "John Plummer", "Jacob", etc...); $LinksArray("<a href='/john_plom'>%s</a>", "<a href='/john_plom'>%s</a>", "<a href='/jacob_d'>%s</a>", etc..); //%s shout stay the the same as the input of the $text. ...

Pre-populating input in Java console

I'm making a console-based Java/Groovy application that does a lot of find/replaces in text files. If, say, the program knows you replaced foo with bar last time, it should by default know you probably want to replace the next foo with bar as well. My idea was to pre-populate the input field of the What would you like to rename this to? ...

Java: Changing an xml node name without using renameNode()

Hi, I've been renaming xml nodes using the document.renameNode() method: Document document = loadXml(xml); NodeList list = document.getElementsByTagName("Entry1"); for (int i=0; i < list.getLength();) { document.renameNode(list.item(i), "", "Entry"); } However, the Java version I'm deploying to (1.5.0_09-b03) doesn't suppor...

replace words in text ignore urls

i use this line to search for a name in text with url's. $name = "xxx"; $text = "my name is xxx en my website is http://xxx.something.com"; $text = preg_replace("/\b(".preg_quote($name, "/").")\b/i", $url, $text); how can i change this regex to ignore urls in the text ...

Replace regular expression with \t in Notepad++

Hi guys, simple example in Notepad++ using RegEx replace search for: anything replace with (wanted): \test guess for regex replace string: \test results in: tabest, so the \t is interpreted as a tab guess for regex replace string: \\test results in: \ tabest, so the first \ is interpreted as a \, the \t is interpreted as a tab guess f...

How to replace row value in SQL Server?

My table contains some rows like below Lcd - projector A & A products saranvana store LG - television IFB - fridge samsung - Monitor I want to replace space (special char) instead of - (hyphens) in all records ...

How can I replace any word within a string that starts with an '@' symbol like Twitter does, in Javascript/JQuery?

I'm trying to make any '@sometext' an HTML link where 'sometext' is also appended to a url. i.e. '@sometext' becomes a link to 'http://someurl.com/sometext'. But so it can change because the link will be different everytime depending on what 'sometext' is. I'm writing this in javascript and jquery. I'm trying to recreate links similar to...

Using SED to append a string to an existing line of text?

Hi, I'm trying to use the linux sed command to append a path element to the RewriteBase in a .htaccess file. I have tried it with this arguments: #current RewriteBase is "RewriteBase /mypath" sed -ie 's/RewriteBase\(.*\)/RewriteBase \1\/add/g' .htaccess with this result: addriteBase /mypath So sed overwrites the the beginning of ...

Replace balanced brackets with balanced braces in LaTeX

How can I write a (La)TeX command that replaces all [ with { and all ] with }, assuming that every [ has a matching ], and that any braces between the [ and ] are balanced? It needs to be able to deal with nested brackets. For example, I want to be able to write a command \mynewcommand so that \mynewcommand{{[[{1}{2}][{3}{4}]]}} is the...

Visual Studio 2008 likes to insert random strings into my code

Here's the setup: I have some controls with text fields that I wish to be blank. So I might have, in my designer file: someControl.HeaderText = "" or someControl.HeaderText = Properties.Resources.blank_string THis only seems to happen when i'm trying to specify a blank string for a text or headertext property to a control. If I op...

C++ simple string replace, non complicated code, but producing crazy error

First, thank for you all your help! The error I am getting is: Unhandled exception at 0x7c812afb (kernel32.dll) in Readerboard.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0012f8a8.. I have found the problem to be with this line: str.replace(str.find(sought), sought.size(), replacement); It is lo...

Pass a variable into regex with string replace.

I have a complicated regEx inside a string replace and I want to use a variable called "tagname" instead of the word Category, but I don't know how to do this. $("textarea").val().replace(/\<Category\>(.*)\<\/Category\>/gi, "<Category>TextVariable</Category>"); I have tried something like this, but it didn't work in the first paramet...

Why do I get an error message that .replace is not a function?

I have this function: function countLitreKgSums(cProductIds){ var cLitreKgSums = new Array(); var cWeek = 0; for(i=0;i<cProductIds.length;i++){ var cLitreKgSum = 0; $("#plan_table td[class='week']").each(function(){ cWeek = $(this).html(); var cLitreKgValue = $("input[name*='plan_table_week" + cWeek...

Jquery: When adding submit button, it cannot be selected again.

Hello there, I would like to add a button to the current page using html()-function. This button needs to be selectable, and alert('click') when it is clicked. This seems impossible. Look at this code <script type="text/javascript"> $(document).ready(function(){ $('a').click(function(event){ $('div').html('<form method="p...