Regex: Find Ampersands But Ignore HTML Entities?
Jan 27, 2010
I'm trying to write/find a regular expression for finding ampersands but not HTML entites.I have this which finds entities but can't figure out how to ignore entities and return unmatched "&"
&[^s]*;
Test string: This is sample test containing a bunch of & and entities. Do you shop at: M&S? &x#1234;
I want to HTML encode the non-entity ampersands for insertion into XML e.g.
"bunch of & and" --> "bunch of & and"
View 9 Replies
ADVERTISEMENT
Jul 18, 2009
We have been using the following js/regex to find and replace all non-alphanumeric characters apart from - and + outputString = outputString.replace(/[^w|^+|^-]*/g, "");
However it doesn't work entirely - it doesn't replace the ^ and | characters. I can't help but wonder if this is something to do with the ^ and | being used as meta-characters in the regex itself.
I've tried switching to use [W|^+|^-], but that replaces the - and +. I thought that possibly a lookahead assertion may be the answer, but I'm not very sure how to implement them.
View 12 Replies
View Related
Nov 22, 2006
I need some help with Javascript and HTML entities. I am writing some code and I need to use quite a few HTML entities on alert boxes (messages in different languages)
Unfortunately Javascript displays the entities and not the equivalent caracther.
View 10 Replies
View Related
Feb 17, 2006
How can I convert some html entities (polish) to a character which I can use in a javascript alert?
The entities are:
ń
ę
ń
ą
ż
ś
ć
View 2 Replies
View Related
Jul 20, 2005
Using my IE v.6 browser, document.write doesn't convert HTML entities
(e.g. ', &) to the appropriate character (though NS 6.2 works
fine).
Obviously I can get round this for particular entities by writing some
code to do the conversion before using document.write - but I need a
more general solution that will catch any of the HTML entities.
A trawl with Google has found a number of people raising the question,
but no answers. Any suggestions?
View 4 Replies
View Related
Jun 18, 2010
I have a large set of input fields (of checkboxes and radio buttons), and aside each set, is a clear button (just looks like text you can click on) that clears any input next to each of the input fields. When no input buttons are selected, the HTML entities that depend on them are supposed to disappear, and this works on load.
My question is how does one easily incorporate that clear button so that it tells the listeners already in action to clear those entities when they click on clear, and without having to manually do it over again with the clear button, if that makes any sense.
[Code]...
View 2 Replies
View Related
Mar 14, 2007
I need to figure out a pattern that can match each letter of the message, but leaves all the html entities alone.
For example, I have a input like this:
<div>
This is the content < Hello >
</div>
Just as an example to make it more clearer, If I wanted to replace the all letters of the message with the number "1" I would have this result:
<div>
1111 11 111 1111111 < 11111 >
</div>
View 2 Replies
View Related
Jun 11, 2010
I am using the ajax method in JQuery to return an XML response from a URL location. The method looks like the following:
$.ajax({
url: '../DSMO/lb.asmx/GetAvailableDocListAuth',
cache: false,
type: 'POST',
[Code].....
OK so if I use repsonseText responseXML or just try and traverse msg it will not work. The problem is the body of my XML response, all of the tags ('<' and '>') are getting escaped to html entities ('<' and '>') So it becomes a malformed XML document that is not readable. I even tried using the Javascript function replace to go through and replace with no luck.
Even stranger if I access the web service through the browser, the XML is just fine!
The server is Windows Server 2008 running IIS 7 and I am programming of course in HTML and newest version of JQuery.
The browser I am testing on is Firefox with FireBug.
View 5 Replies
View Related
Jan 3, 2007
I am trying to parse a HTML page and want to replace the input element The following code fails all the time.
var ex = "<input type="hidden" name="__VIEWSTATE"
id="__VIEWSTATE"
value="/wEPDwULLTE2NjEyNTI0MThkGAEFEHNlY3Rpb25zR3JpZFZpZXc PZ2QN271==
/>";
var regEx = new RegExp("<s*input[^>]*>(.*?)s*/");
if (ex.match( regEx))
{
alert('match');
}
else
{
alert ('no match');
}
View 1 Replies
View Related
May 19, 2009
I need Regex to find all the following:
http,https,ftp,news,file
With a case-insensitive search, and then I need to convert to URL safe string i.e. %2E%2D etc
This is about as far as I got:
Code:
String.replace(/http/gi,"")
Not very strong with Regex.
View 2 Replies
View Related
Oct 8, 2009
I would like to strip HTML out of a string I have in a JSON item I have. I'm using Yahoo! Pipes to aggregate several blog-feeds and put them in together in one big feed, I then use jQuery to parse that JSON and place it onto my page. My issue is though that what's being parsed onto my page is the raw html code within the JSON item. I want any HTML related tags out of the item, so I just see text.
View 1 Replies
View Related
May 16, 2006
I need some help creating some regular expressions that remove specific html tags...the script/expression will run when a button is clicked (i.e. "Remove Bold" button will remove <b> </b>).
currently I have these expressions working but they do not accomplish what exactly what I am after...Actually the functionality I'm looking for will incorperate both, however I can't seem to get it to work properly...
data.replace(/<[^>]+>/ig,"")+""); - this removes all tags (no matter what kind), I would like it to be a little less "greedy" and only remove specific tags.
i.e:
Input = <u><b>THIS IS SOME DATA</b></u>
Output= THIS IS SOME DATA
data.replace(/<(B|b)[^>]*>[^<]*(</B>|</b>)/ig,"")+""); - this removes bold tags and will leave other tags like <u> behind, exactly what I was looking for. However, it also removes the content/data that is wrapped in the tag.
i.e:
Input = <u><b>THIS IS SOME DATA</b></u>
Output= <u></u>
In the above example what I would like to happen is:
Input = <b><u>THIS IS SOME DATA</u></b>
Output= <u>THIS IS SOME DATA</u>
Any suggestions?
View 10 Replies
View Related
May 21, 2009
I need to parse an an HTML page and pull what ever values are in these JavaScript tags. There will usually be multiple tags with different values between the single quotes. The value in the next example I need to pull into my array would be 'A728'. Here is an example code..
View 2 Replies
View Related
Oct 19, 2011
I'm trying to write a RegEx function that will remove all HTML tags AND the content in between.
I'm finding a lot of functions that will strip out JUST the tags (leaving the in between content), or will remove tags and content for specific tags only (or will allow only specified tags, removing all else.) But I can't quite seem to write a mask that will take out ALL HTML tags and their content.
Here is the mask I have now (fiftieth version of it, anyway):
Code:
/<s*[^>]*?>.+?</s*1s*>/gi;
View 7 Replies
View Related
Mar 26, 2009
how to find certain text within two specified text? In my example I have:
<asset:search
type=�asset type�
[subtype=�asset subtype�][code]...
I need to find through pages of code looking for "localfields=" between "<asset:search" and "/>".
View 5 Replies
View Related
Jul 3, 2011
I have a file that generates web galleries in Adobe Lightroom. They are generated depending on which files are selected and the metadata in those files.
Basically it is a series of pages of thumbnails called index.html index_1.html index_2.html etc.
Then a set of pages for each individual image.
An example can be seen here: [url](the page navigation links are not great, but I have addressed that, they're at the bottom >> )
Currently if a user clicks on a photo there is a 'return to thumbnails button at the top, but this always takes them to /index.html
So the user could be at a picture after browsing to /index_39.html and still get returned to /index
Is there any way I can use history.go to find the last instance of index.html Or index_x.html (where x is any number) and take them back to that instead?
View 1 Replies
View Related
Jul 23, 2005
I would like to set the value of a hidden input field to the value of
a javascript variable.
In HTML I have successfully done this by:
<input type="hidden" name="context" value="&{exists};"/>
However I now wish to put this into an xsl file and it complains about
the { characters.
If I change them so that I have:
<input type="hidden" name="context" value="‹exists›"/>
Then I get an error along the lines of the entity lsaquo was
referenced, but not declared.
View 2 Replies
View Related
Feb 25, 2006
Modified with a newer version since it was first posted. Some comments may refer to older versions.
function entity(str, mode) {
str = (str) ? str : "";
mode = (mode) ? mode : "string";
var e = document.createElement("div");
e.innerHTML = str;
if (mode == "numeric") {
return "&#" + e.innerHTML.charCodeAt(0) + ";";
}
else if (mode == "utf16") {
var un = e.innerHTML.charCodeAt(0).toString(16);
while (un.length < 4) un = "0" + un;
return "u" + un;
}
else return e.innerHTML;
}
entity() has two parameters:
- entity: is a string which can be either a named entity (»), numeric entity (»), UTF-16 value (u00bb), or even the character itself (»).
- mode: is an optional value that can be 'string', 'numeric', or 'utf16'. This tells the function what to return the value as. Defaults to 'string'.
You'd use it like this:
// String mode
var div = document.createElement('div');
var text = document.createTextNode('Parent '+entity('»')+' Child');
div.appendChild(text);
// Numeric mode
var description = "The entity for » is "+entity('»', 'numeric');
// UTF-16 mode
var description = "The UTF-16 value for » is "+entity('»', 'utf16');
View 3 Replies
View Related
Mar 26, 2010
With js I am trying to find and replace any prices within the innerHTML?
Matching e.g.:
$25.00
$15
$1000.45
$1000,999
I want to find all instances of these and replace them with alternative strings.
View 7 Replies
View Related
Nov 6, 2011
I'm trying to accomplish the following, preferably using jQuery, find this string on a page (it occurs only once).. 'BC-' and then, depending on the page i'm on either - add a simple <br/> tag before it, or enclose in it within a span tag with a class. adding the span would be more complicated because 3 numbers follow the BC- ex: BC-103.
View 5 Replies
View Related
Sep 22, 2011
This code was working fine until I added "["lastname"]["email"]" to it. Why has this problem developed? Was I suppose to separate them or something?
<SCRIPT type="text/javascript">
function validateForm() {
var x=document.forms["form"]["firstname"]["lastname"]["email"].value;
[code]....
View 2 Replies
View Related
Aug 4, 2010
I wrote a function in PHP that converts characters for large strings. Here is the entire array:
[Code].....
View 2 Replies
View Related
May 27, 2010
I have been using JQuery in the past 6 months and I really got in love with it!Finally,I've come to an issue that (probably) have better solution than the one Im trying to do with.I have multiple tables in a HTML [code]all of these tables are some kind of gridviews filled with data using JSon and JQuery.The problem is:Before filling with data, only this part in the DOM is created <table id="myTableId"> <tbody> !so, before going forward with filling the table with data and creating <tr>'s and <td>'s, I would like to find the current (not filled one) table ID.The algorithm would be:
1. <table id="mytableId"> is generated
2. right after #1, find table ID.
3. Depending of the table ID, generated data accordingly. (Continue with creating tr's and td's)
I have tried using closest('table'), also using find(), parent(), parents() and some other methods with which I've been working previously, but still no success.I can find the table by uing var tId = $(TABLE['id*='myTable']").attr('id');, but this finds all tables with 'myTable' and I want to find only the one that is created at that moment and waits for filling with data.
View 1 Replies
View Related
Jul 8, 2010
I Use the regular expression to find the html tags present in the input box, It works properly in IE & FF but in chrome it works fine when use first time for an input box but not again, below my code...
function IsWithinTags(inputString) {var regExp = /</?[^>]+(>|$)/g;
inputString = inputString.replace(/&(lt|gt);/g, function (strMatch, p1) {
return (p1 == "lt") ? "<" : ">";
});
[Code]....
View 1 Replies
View Related
Jan 22, 2006
I have an num -569360386, and turn it into hex format.
I use toString(16),I get -21efc002.
But how can get 0xDE103FFE,which is to ignore the highest bit as the
signed bit?
View 11 Replies
View Related
Oct 13, 2009
I am trying to read data from excel file and use the same to populate a select menu. If any cells are blank, I want to ignore. But I am unable to do this. The dropdown gets populated with blanks. Following is the peice of code:
var excel_cell = excel_file.ActiveSheet.Cells(i,1);
alert(excel_cell);
if(excel_cell=='undefined')
[code]....
View 3 Replies
View Related