Replacing A Regex Match With Changed Matched Results?

Mar 20, 2011

I was trying to do something similar to code highlighting but can't find a good way to do it. For example lets take this code:

def some_function():
something()
somethingElse()
def some_other_function():
something2()
somethingElse2()

[Code]...

View 3 Replies


ADVERTISEMENT

JQuery :: Regex And A Span That Can Not Be Changed?

Mar 17, 2011

Pardon me if i'm a bit confused while trying this jquery.This week I'm with jquery almost in every day..

[Code]...

View 1 Replies View Related

Return Match Using Regex

May 18, 2007

I have been working on this for a few hours and am frustrated
beyond all extent. I have tried to research this on the web as well
with no success. I am trying to match certain contents within a
wrapper div. So for example if the inside of the wrapper div was the
following:

<div id="wrapper">
<a href="#">a great link that contain text and symbols</a>
<div... </div>
<div... </div>
</div>

I would like to strip out all the internal div's. But because there
can be alot of internal div's, I figured it would be less processor
intensive to just match the first 'a' tag and repopulate the wrapper
div with the match. I am trying to use something like the following
regex:

re = /^<a(.+)</a>/;

with the following statment:

$temp = document.getElementById('wrapper').innerHTML.match (re);

but this is returning the entire contents of the wrapper div. I have
tried variations of the regex and either continue to get the entire
contents or null returns. Any help would greatly be appreciated.
BTW, I can't match to the first because the contents may be touching (ie ...</a><div>...).

View 3 Replies View Related

Match Title Using Regex?

Jun 17, 2010

I am willing to know how to match a website s title using regex.

View 4 Replies View Related

Replacing Element / Doc Write From Regex

Apr 23, 2010

var bakaBanner;
bakaBanner = document.getElementById('head');
if (bakaBanner) {
var str=//images/banners/[A-Za-z0-9_]+.[a-z]+/;
document.write(str.replace(//images/banners/[A-Za-z0-9_]+.[a-z]+/, "http://img218.imageshack.us/img218/5904/revyblacklagoon1.png"));
}

Alright, here's the deal... This is a script to be used in Greasemonkey. The page this is for changes their banner every 5 minutes, the name changes and it could be either jpg or png.

I'm fairly certain my regex itself:
/images/banners/[A-Za-z0-9_]+.[a-z]+
Is correct... Here's an example of what it's looking through:
<div id="head" style="background-image: url(/images/banners/kiminitodoke.jpg);" >
<div id="header_left">
<div id="rss">

My guess is that it has something to do with this line:
document.write(str.replace(//images/banners/[A-Za-z0-9_]+.[a-z]+/, "http://img218.imageshack.us/img218/5904/revyblacklagoon1.png"));

View 3 Replies View Related

JQuery :: Use Regex To Match A Value In Form Input?

Jul 16, 2010

I'm trying to create a branching form wherein the user selects a date using the datepicker plugin, then, depending on whether they choose a weekday or a Saturday, they are presented with one or the other of 2 select lists to choose the time.

I'm just getting started, and I can't seem to get the regex right. Here's a simplifed version of the relevant part of the datepicker,

$(function() {
$(".datepicker").datepicker({dateFormat: 'D, mm-dd-yy',buttonText: 'Click Me!', });
});

and here's the initial test to see if the chosen date falls on a weekday or a Saturday:

$(document).ready(function() {
$(':input[name=datepicker]').change(function() {
if ($(this).val()!=/^Sat,.*/)
{

[Code]....

View 5 Replies View Related

Match Regex Globally Then Loop Through Result?

Mar 27, 2011

I've got the current script which returns 1 match in matches[0] with a url, but I need it to return ALL occurrences in the string.And then I need to know how to loop through the matches and display each "url" in this case.Nothing I've tried seems to find more than 1 match even when [string] contains a list of urls, which indicates I've done something wrong.

View 1 Replies View Related

RegEx - Match Non-alphanumeric Characters But Ignore?

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

Calling Regex's Test Twice Returns Opposite Results

Jun 29, 2010

If you call the below code, it will incorrectly print "true, false" when it should be "true, true". WHy is that? How do I fix this?

Code: isCapitalLetter = /[A-Z]/g;
//Incorrectly alerts "true,true"
alert( isCapitalLetter.test( "lineHeight" ) + "," + isCapitalLetter.test( "lineHeight" ) );

View 3 Replies View Related

Way To Add Css Class / Id To Element When Matched With Another

Jul 25, 2010

I've got a scenario where i've got a list of text names on a page and a rotating gallery of images. Each image relates to one of the names. What i would like to do is highlight the name by adding a css class or id when the related image comes into focus.

I'm sure i can do this by using the rel element to relate to the id of the image (or the other way round!) but i'm not sure exactly how. I presume it's using jquery live and matching with selectors.

I'm using jquery and the galleria plugin.

View 2 Replies View Related

JQuery :: Getting Only Matched Element With Clone

Feb 22, 2010

I'm a starter in using jQuery and I decided to work my way through the 'Learning JQuery' book from packt.Somewhere in Chapter 5 they use the clone() function with the false attribute. The JQuery version used in the book is 1.1.3a. With the clone(false) method the writer can clone only the matched element and not the descendants. And that works in 1.1.3a.I know that this is no longer the case in JQuery 1.4. Boolean is only for Event Handlers.But what is the new equivalent of this method? In other words. How can I clone an element with only the matched element and not it's descendants?

View 2 Replies View Related

JQuery :: Select Every Nth Element From A Matched Set?

Mar 24, 2011

I know you can use :even or :odd to get the even or odd indexes from a set, or :lt/:gt to filter down the matched set before/beyond the specified index. But what if I want to select every 5th element? And I know it's not nth-child, because that selects everything that is the nth-child of it's parent and not if it is one of the nth elements in the matched set. Is the only way to use .each(function (index) {...}); and then check if the index makes that element one of the nth items?

View 2 Replies View Related

JQuery :: Highlight Matched Text Using Autocomplete?

Oct 15, 2010

I have spent the last week trying to figure out how to do the following: User types some text in a text box. The autocomplete queries a php script that returns JSON of matched values. I have got thedrop down list to show these values but I cannot for the life of me get the matched characters to turn bold. For example, if the user types in "rav" and my list contains:

RAVEN
RAVE
RAVEL

then I want it to appear as

RAVEN
RAVE
RAVEL

My current JS code is as follows (along with HTML):

$(function() {
$( "#query" ).autocomplete({
source: "get_json.php",

[code].....

View 6 Replies View Related

JQuery :: Selector Only Selects One (last) Of Matched Classes

Aug 25, 2010

I have code to add a row dynamically to a form in my page when an element with class 'addRow' is clicked. The tables (2 tables in one page) that I want to add the row to have class 'tableAddRow'. The tables are contained in a form. But for some strange reason the code only adds to the last matched table in the page. I tried using the $.each selector but nothing works.

Here is the code:
$(document).ready(function(){
$(".addRow").click(function(){
$(".tableAddRow tr:last").clone().insertAfter(".tableAddRow tr:last");
$(".tableAddRow tr:last input").val("");
});
});

View 5 Replies View Related

JQuery :: Incrementally Hide Items From Set Of Matched LI Elements

Aug 19, 2010

I am new to jQuery and I am having trouble with the syntax, selectors and refining when trying to create functions. What I am trying to achieve: I have a gallery consisting of a ul with images placed in vertically stacked list items. The ul is in a fixed size wrapper with overflow:hidden so only the first list item displays. The user clicks a button and the first li is hidden using hide(400). This makes the other list items flow up and reveals the second list item within the wrapper window.

When the last list item is visible, the click will show(400) all of the list items again, causing them to flow back into order and only the first item will be showing again. Further clicks will repeat this process from the beginning. I know what I would like to do in terms of code, but I am having trouble with the correct syntax, selectors and refining. I have included the html and description version of the code I was hoping to create. I know the code could be much more efficient by placing functions into variables and testing for true false, but I would like to see the steps with my longer code description for learning purposes. Perhaps afterwards someone can blast it off in two lines.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list hiding test</title>
<style>
.listWrapper {
height:25px;
width:380px;
background-color:#d6d6d6; .....

View 2 Replies View Related

JQuery :: Addclass Function Only Works With First Of Matched DIVs

Jul 16, 2009

I'm having an annoying issue with addClass(). I'm trying to find all divs with id name '#moldura_slides' and add the class '.horizontal' to each one of them. The problem is that only the first div matched gets the class. The others are just ignored and don't get it.
$(document).ready(function(){
$("#moldura_slides").addClass("horizontal");
});
This is the page: [URL]

View 3 Replies View Related

Call Web Service And Retrieve Xml File Contains The Matched Data?

May 3, 2010

i have a web service at this url http:[url]....i use hotel search file with HotelSearch method and method will retrieve xml file contains the matched data. the varialbe that i made post with it is named : HotelData

the data of the variable is a string file that contains an xml data like this

<HotelsParameters>
<CityID>388</CityID>
<UserName>admin</UserName>[code]....

the data in input filed is the previous xml file

View 4 Replies View Related

JQuery :: Find And Manipulate Matched Attribute Values?

Dec 9, 2010

Code HTML4Strict:
<div id="veg">
<a title="Tree" href="x.html"><a>
<a title="Leaf" href="y.html"><a>
</div>
 
[Code].....

Each anchor is unique, but the title attribute may match the exact title of one or more images. Where a match is found, either once or more, the title text is copied - once - into the anchor element.

How to do with jQuery?

View 4 Replies View Related

JQuery :: Delegate Without Events / Call Function When Selection Is Matched

Apr 15, 2010

I tried to use delegate, but it is bounded with events. I don't really want to execute a function on a standard event. But I would need to change the elements that match a selector, when they appear in dom. Is possible to "unhook" delegate from events?like for all existing and new elements with class ".red" to add to the "data" a new key "initiated:true".

View 2 Replies View Related

JQuery :: Event.target - Click Anchor As Matched Element

Jun 1, 2010

consider the following code;

$("#content").click(function(event)
{
if($(event.target).is('a'))
{
$(this).//do something
}
}

I'm binding a click event to a div so that I can see whether is was the div or some element inside the div that has been clicked. When the if() in my code evaluates to true $(this) is still equal to $("#content") whereas I'd like to have the clicked anchor as matched element. How would I do this?

View 2 Replies View Related

Onlick Open New Window If Text Input Matched That Is Printed To The Page?

May 7, 2009

I have everything working accept the last part and I don't know what to do.function show() works and shows data entered in text box.function open_win() works,but I only need it to open when there is a input match say like the name Tom,otherwise I want function show() just to show the input.

Currently the new window opens every time the button is pressed needs to match input string only before window opens and then string print to window I think these two lines are the problems(whatever the input) document.getElementById('myDiv').innerHTML = string; And var bselect= "Tom" open_win(); I think I need to set var to the string printed to page to solve the last part. how to I get the blank window to the center of screen,as it covers the data in the function show.

Below is my code thus far :

<html>
<head>
<title>Input</title>
<script>

[code]...

View 4 Replies View Related

Getting The Name Of The Field That Has Had Its Value Changed

Feb 12, 2011

I have a input field array, and have associated a change JQuery event handler if the value of any of the fields in the array have changed. So:

PHP Code:

And..

PHP Code:

In the Javascript, how can I retrieve the name (or index to be more precise) of the field that has had its value changed?

View 2 Replies View Related

Capture When A Textbox Has Changed!

Jul 23, 2005

Does anybody of you have a good algorithm to capture when a value in a
textbox is changed? I'm using the keypress/keydown events but they seems to
be a bit inconsistent (IE and Mozilla). Basically what I want is to set is a
"isDirty" flag when a user has changed any value in the textbox (or in a
dropdown) and then if he/she tries to leave the record without saving I want
to give a save warning. Since I don't want set the isdirty flag if you for
example klick tab, certain F-buttons, arrows (up/down/left/right) etc I
tried to capture the keypress/keydown event and ignore specific keycodes.
Since there are several keycodes that should be ignored I was hoping there
is a better solution.

View 7 Replies View Related

How To Check That A Form Has Been Changed

Apr 30, 2006

How do you detect that a form element has been changed? This thread:

http://groups.google.com/group/comp...25a82c9be127790

suggests that you attach onChange event handlers to every form element,
and when the handler fires you update a global 'isChanged' variable.
This technique seems to be a bit messy to me (I have many form
elements), I was thinking about storing the original form object in a
javascript variable when the body loads (in the bodie's onLoad event
handler), and upons submission, doing a javascript equality comparison
with the current form object. If nothing has changed, then the two
objects should be equal, right?

if(oldObject == document.getElementById('form'))
{
alert('has changed!');
}

Would this work?

View 19 Replies View Related

Date Format Changed In IE7 But Not In FF?

Jun 3, 2009

After fetching a timestamp via sql,I return to javascript to do the formatting. Actually, I was first doing a bit of formatting in php to change from yyyy mm dd hh:mm (as saved in db) to mm dd yyyy hh:mm as I found the 1st not to work with the Date() function in FF.Consider the following...

var date_from_server = "06 03 2009 01:37";
var jsDate = Date(date_from_server);

In FF jsDate is "Thu Jun 03 1909 01:37:00 GMT-0700 (Pacific Daylight Time)".In IE7 jsDate is NaN.I've tried a few different formats. Does IE7,s Date() function not allow an arg at all or only of a certain format?

View 3 Replies View Related

Previous Value Of A Changed <SELECT>

Jan 29, 2004

I have a form where users need to be able to change a particular value in a <select> but need to confirm that this is what they want to do under certain circumstances. I have the script firing up ok and prompting the user, but I'm darned if I can figure out how to undo the change if required.

What I want to do is something like document.form.object.value=document.form.object.oldvalue but I have no idea what the correct properties are.....

So, how do you roll-back the selection in a <select>?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved