How to write a group of substitude (la->lb), (lb->lc), (lc->la) as a regular expression
I need to do it in vim (MacVim) and use it in one line. z.a2=cross(z.b, z.c)(z.b1, z.c1); became z.b2=cross(z.c, z.a)(z.c1, z.a1); Thank yo ...
I need to do it in vim (MacVim) and use it in one line. z.a2=cross(z.b, z.c)(z.b1, z.c1); became z.b2=cross(z.c, z.a)(z.c1, z.a1); Thank yo ...
This is a question in my paper test today, the function signature is int is_match(char* pattern,char* string) The pattern is limited to only ASCII chars and the quantification * and ?, so it is relatively simple. is_match should return 1 if matched, otherwise 0. so, how to do, i am really dizzy on this? thanks in advance! ...
Hello all, I have this regex which is supposed to remove sentence delimiters(. and ?): sentence = sentence.replaceAll("\\.|\\?$",""); It works fine it converts "I am Java developer." to "I am Java developer" "Am I a Java developer?" to "Am I a Java developer" But after deployment we found that it also replaces any other dots in th...
Hello, My genius IT Analyst decided at the last minute she wants ALL trademark symbols to be 2 sizes smaller than it's surrounding text. Since we don't have time to add tags to the entire template and CSS, we need a quick fix. How can I replace ALL instances of the TM symbol with something like "<span style="font-size:1em;">™</span>" ...
I am trying to break the following sentence in words and wrap them in span. <p class="german_p big">Das ist ein schönes Armband</p> I followed this: http://stackoverflow.com/questions/2444430/how-to-get-a-word-under-cursor-using-javascript $('p').each(function() { var $this = $(this); $this.html($this.text().r...
Hi, I have string "(1,2,3,4,5,6),(1,2,3)" I would like to change it to "('1','2','3','4','5','6'),('1','2','3')" - replase all parts that mathces /([^,)("])/ with the '$1', '$2' etc ...
I want to search the text property of my twitter status objects and swap out @username for <a href="http:/twitter.com/username">@username</a>. What I have tried so far looks like this: $pattern = '/([@]{1})([a-zA-Z0-9\_]+)/'; $replace = '<a href="http://twitter.com/\2">\1\2</a>'; $new_string = preg_replace($pattern, $replace, $...
I never use regular expression before and plan to use it to solve my problem but not quite sure whether it can help me. I have a situation where I need store a rule or formula to build string values like following examples in a database field then retrieve this rule and build the string value. FacilityCode + Left(ModelNO,2) Right(PO,3...
How to make regular expression in PHP? Can anyone guide me to the basic rules to make regular expressions? ...
I've got the these strings: /search/keyword.html and /search/keyword/1.html # the 1 represents the current page Now I want to write a regex that matches the keyword, and the page, if given. $1 (the first match) should always be the keyword (keyword). $2 should be the page, if there is one (1). I tried this but it doesn't work...
I am trying to write a regex in Java to get rid of all heading and tailing punctuation characters except for "-" in a String, however keeping the punctuation within words intact. I tried to replace the punctuations with "", String regex = "[\\p{Punct}+&&[^-]]"; right now, but it will delete the punctuation within word too. I also trie...
I need to do a huge replacement on my site 400+ items with the new asynchronous tracking. pageTracker._trackEvent('footer_search', 'search', 'search-footer'); Im using aptana and it has a regex replacement, it needs to look like this, notice the [ ]. _gaq.push(['_trackEvent', 'footer_search', 'search', 'search-footer']); Much appr...
I need to find and replace text in a case insensitive way, unless it is within an anchor tag - for example: <p>Match this text and replace it</p> <p>Don't <a href="/">match this text</a></p> Searching for 'match this text' would only replace the first instance. [Edit] As per Gordon's comment, it may be preferred to use DOMDocument in...
I have an HTML string like so: <img src="http://foo"><img src="http://bar"> What would be the regex pattern to split this into two separate img tags? ...
Imagine we have a long string containing the substrings 'cat' and 'dog' as well as other random characters, eg. cat x dog cat x cat x dog x dog x cat x dog x cat Here 'x' represents any random sequence of characters (but not 'cat' or 'dog'). What I want to do is find every 'cat' that is followed by any characters except 'dog' and the...
Let's assume I have the following text: "something [234][3243]" I am trying to pull the values in between the square brackets. I came up with the following regex expression: .*\[(.*)\].* however this only allows me to pull the last value in between the brackets, in this example 3243. How do I pull all values, meaning get more groups ...
I'm sure this has already been asked and answered, but I honestly couldn't find my answer after searching for quite a bit and reading Regex Tutorial. What I'm looking to do is match a string that has the same characters and length as another string. For example, a string "abcde" would match "edcba" but would not match "abcdf" or "aabbc...
I want to take strings like: Submit Changes Create New Update Record Save Item and convert them to: Submitting Changes Creating New Updating Record Saving Item with a function like: var ConvertToProgressivePresent = (function(){ // cache this regex var rProgressivePresent = /\b(?:(Submi(t))|(Creat|Sav|Updat)e)\b/i; r...
I am working on patching the Zoidberg Perl shell to fix some errors that modern Perl versions throw when testing. Note, I am not the original author nor am I criticizing him. I came upon an interesting problem that I would like a little history on. The code below takes an array of inputs and for each strips off and ending sigil. Then i...
Hi everyone. I need to allow only alphanumeric characters (with uppercase) from 0-25 chars length and no lazy all-repetition numeric value. I've got the first part: Regex.IsMatch(tmpResult, "^[0-9A-Z]{0,25}$"); (that's easy) 111112 - match AABD333434 - match 55555555 - no match 555 - no match Could anyone please help me with this? ...