[Solved] Find and parse url in dom-element value using RegExp and jQuery [closed]

Try: var value = $(“param[name=”movie”]”).val();//get attribyte value if(value && (value = value.match(/secEncCode=(\w+)/))){//reg exp value = value[1];//get first pocket console.log(value);//res } http://jsfiddle.net/xbQxw/ update by comment If you want change secEncCode value: var param = $(“param[name=”movie”]”),//get obj value=param.val(),//get attribyte value key; if(value && (key = value.match(/secEncCode=(\w+)/))){//reg exp key = key[1];//get first pocket param.val(value.replace(key, “YOUR NEW KEY”));//replace key … Read more

[Solved] Regex for finding the second occurrence of a character in a dynamic string in javascript

const regex = /(.*?&.*?)&.*/; const str = `https://www.bing.com/search?q=something+something+something+something&mkt=en-IN&organic=True&ads=False&snippet=False`; const result = str.replace(regex, ‘$1’); The regular expression searches everything before the second “&” and replaces the original string with this match. solved Regex for finding the second occurrence of a character in a dynamic string in javascript

[Solved] How to get attribute of href on the basis of selected text? [closed]

Try this : put id for anchor tag <a id=”anchor1″ href=”https://stackoverflow.com/questions/25931155/site.com/register.php?mid=username&mode=bn&bid=1″> use below javascript <script> var href = document.getElementById(‘anchor1’).href; //get index of ? var indexStart = href.indexOf(‘?’); var indexLast = href.length; //get href from ? upto total length var params = href.substring(indexStart+1, indexLast); //get tokens with seperator as ‘&’ and iterate it var paramsArray = … Read more

[Solved] Incrementing only the digits from an alphanumeric string

Extract the number from the string then increment it and put it back, e.g. using String.replaceXxx() and Integer.parseInt() etc. If you want to increment multiple independent numbers, try this: String input = “ABC999DEF999XYZ”; //find numbers Pattern p = Pattern.compile( “[0-9]+” ); Matcher m = p.matcher( input ); StringBuffer sb = new StringBuffer(); //loop through all … Read more

[Solved] Regex patterns for AANNN and ANEE formats [closed]

I’m assuming you want ASCII letters and digits, but not Thai digits, Arabic letters and the like. AANNN is (?i)^[a-z]{2}[0-9]{3}$ ANEE is (?i)^[a-z][0-9][a-z0-9]{2}$ Explanation The ^ anchor asserts that we are at the beginning of the string [a-z] is what’s called a character class. It allows any chars between a and z. In a character … Read more

[Solved] Quotes for values of html attributes [closed]

The escaped quotes match each other in the HTML string that you’re creating. The quotes are not “surrounding” +i+. They’re being used to end the string that begins with “<p id=\”element” and to begin the next string: “\”>Hello world, …” This is concatenating i between these two strings. So if i contains 0, the resulting … Read more

[Solved] Split a string with letters, numbers, and punctuation

A new approach since Java’s Regex.Split() doesn’t seem to keep the delimiters in the result, even if they are enclosed in a capturing group: Pattern regex = Pattern.compile( “[+-]? # Match a number, starting with an optional sign,\n” + “\\d+ # a mandatory integer part,\n” + “(?:\\.\\d+)? # optionally followed by a decimal part\n” + … Read more

[Solved] How to Write Regular Expression for Indian Names [closed]

If you want to catch all strings containing only upper and lowercase characters, periods and spaces, you can use ^[a-zA-Z\. ]+$ Here’s a breakdown of how the regex works ^ matches the beginning of the string [a-zA-Z\. ] matches any character a-z, A-Z, or a period or space     + makes the above match any string … Read more

[Solved] How to Regular Expression match not having a constant at the end of a string (.net validator)

(?> … ) is the syntax for an atomic grouping. And the syntax for look-ahead assertion is just (?! … ). Edit   Try this regular expression instead: .*$(?<!-CONST) The .*$ will consume everything and the look-behind assertion will exclude those that end with a -CONST. Edit    Just for completeness’ sake: If your regular expression language does not … Read more