w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to replace the first occurrence of character 'e' in a string with 's' in oracle?
Try this: select regexp_replace(first_name,'e','s',1,1) from your_table The regexp_replace function is explained here: http://www.java2s.com/Book/Oracle/String_Functions/REGEXP_REPLACE_function.htm

Categories : SQL

Javascript regexp character matching
You do not need to separate chars by , in regex: var list = "[\!@#\$%\^&\*\?_~]"; var your_regex = new RegExp(".*" + list + ".*" + list); if (your_regex.test(password)){ score += 5; }

Categories : Javascript

javascript regExp check last character
You can make it like this ^([A-z0-9_.]{3,14}[A-z0-9])$ Edit after reading your comment ^[a-z0-9][a-z0-9_.]{2,13}[a-z0-9]$ Preview Also I suggest you use flag the i to ignore case: var userIdPattern = new RegExp('^[a-z0-9][a-z0-9_.]{3,13}[a-z0-9]$', 'i');

Categories : Javascript

regexp to find first and last character in a file using grepwin
The only way you can achieve that is using the following regex: (?<!.)^.|.$(?!.) With Dot matches newline checked. The regex above with a "Replace with:" like @ would turn a file like: abc123d3ef1288i zyz23yo21zozzxcvb dj231231sosd In: @bc123d3ef1288i zyz23yo21zozzxcvb dj231231sos@ To just remove the chars, put nothing as "Replace with:" string and hit Replace. Note:By "only way" I mean "Dot matches newline" - there is no other way to test EOF (end of file) if not using "dot matches newline". As far as regex and grouping goes, there are virtually unlimited possibilities.

Categories : Regex

How to replace space/character with specified character after first numeric value in string using C#?
var match = Regex.Match(text, search); //To search for any special character, use @"W" as the second parameter var editable = text.ToCharArray(); editable[match.Index] = replace[0]; text = new String(editable); return text;

Categories : C#

Replace character with a safe character and vice-versa
Maybe you can use url encoding (percent encoding) as an inspiration. Characters that are not valid in a url are escaped by writing %XX where XX is a numeric code that represents the character. The % sign itself can also be escaped in the same way, so that way you never run into problems when translating it back to the original string. There are probably other similar encodings, and for your own application you can use an & just as well as a %, but by using an existing encoding like this, you can probably also find existing functions to do the encoding and decoding for you.

Categories : String

Oracle regexp to ignore repeating characters
You can use regexp_replace() regular expression function with back reference: SQL> WITH t1(col) AS ( 2 select 'hheelllloo wwoorrlldd!!' from dual union all 3 select 'hellow world!' from dual union all 4 select 'ootthheerrss' from dual union all 5 select 'ootthheeerrss' from dual 6 ) 7 select regexp_replace(col, '(.)1', '1') as res 8 from t1 9 ; RES -------------- hello world! helow world! others otheers

Categories : SQL

RegExp replace substring in JavaScript
Use non-capturing parentheses: var q = ['cd', 'bc'].join('|'), re = new RegExp('(?:[:]('+q+'))|(,('+q+')(?=,))|(,('+q+')$)', 'g'), flags = "out:ab,bc,bcc,cd"; flags.replace(re, ''); => "out:ab,bcc" From MDN's Regular Expressions: (?:x) Matches 'x' but does not remember the match. The parentheses are called non-capturing parentheses, and let you define subexpressions for regular expression operators to work with. Consider the sample expression /(?:foo){1,2}/. Without the non-capturing parentheses, the {1,2} characters would apply only to the last 'o' in 'foo'. With the capturing parentheses, the {1,2} applies to the entire word 'foo'. Edit: An explanation of the RegExp /(?:[:](cd|bc))|(,(cd|bc)(?=,))|(,(cd|bc)$)/g There are three sections, separated by pipes. ?:[:](

Categories : Javascript

replace tags in javascript regexp
Perhaps your code should look more like: var win = window, doc = document, bod = doc.getElementsByTagName('body')[0]; function E(e){ return doc.getElementById(e); } function regExpTool(text, outputElement){ this.makeBold = function(options){ outputElement.innerHTML = text.replace(new RegExp('^(<.+>)*('+text+')(</.+>)*$', options), '<b>$2</b>') outputElement.style.display = 'block'; }; } new regExpTool('<div>now</div>', E('wow')).makeBold(); Note, that there is no reason for your makeRegexp method. Here's the http://jsfiddle.net/PHPglue/FjEdg/2/ . It won't work with self closing tags.

Categories : Javascript

replacing only single instances of a character with python regexp
Hmm. It looks like I can get it to work if I used both lookahead and lookbehind. Seems like there should be an easier way, though. >>> re.sub('(?<!$)$(?!$)','z',s) 'za $$b $$$c zd'

Categories : Python

Matching only a non repeated occurrence of a character with Javascript regexp
var r = /(^|[^*])(*)([^*]|$)/; r.test('This is an ex*am*ple'); // true r.test('This is an ex**am**ple'); // false r.test('*This is an example'); // true r.test('This is an example*'); // true r.test('*'); // true r.test('**'); // false In all cases, the matched asterisk is in capture group 2. For a complete solution, not using regular expressions: function findAllSingleChar(str, chr) { var matches = [], ii; for (ii = 0; ii < str.length; ii++) { if (str[ii-1] !== chr && str[ii] === chr && str[ii+1] !== chr) { matches.push(ii); } } return matches.length ? matches : false; } findAllSingleChar('This is an ex*am*ple', '*'); // [13, 16] findAllSingleChar('This is an ex**am**ple', '*')

Categories : Javascript

RegExp issues - character limit and whitespace ignoring
You are missing ^,$.Also the range should be [a-zA-Z] not [A-z] Your regex should be ^[a-zA-Z]{2,}[,]s*[A-Za-z]{2}$ ^ would match string from the beginning... $ would match string till end. Without $,^ it would match anywhere in between the string s* would match 0 to many space..

Categories : Javascript

regexp to modify matches with replace pattern
Try this: var txt = 'some text [2string] some another [test] and [test-]'; var spl = txt.split('[').join("['").split(']').join("']"); console.log(spl); or use simple String.replace(). Working Fiddle

Categories : Javascript

How to use the following Regexp to run as a replace/update sql query in Mysql
No need for RegEx in that case. You can simply use the Trim() function from mySQL. It will simply remove all the white spaces : SELECT TRIM(' removeSpaces '); -------- OUTPUT : [removeSpaces]

Categories : Mysql

MySQL: match period character at the end of string sing REGEXP
From the Specification [[:<:]], [[:>:]] These markers stand for word boundaries. They match the beginning and end of words, respectively. A word is a sequence of word characters that is not preceded by or followed by word characters. A word character is an alphanumeric character in the alnum class or an underscore (_). (Emphasis Mine) A period . is NOT a word character, so you cannot match the end of a word after it. Unfortunately there's no simple way to fix your regular expression, unless you can tell us EXACTLY what you consider a word boundary. If it's whitespace, something like SELECT * FROM table WHERE field REGEXP '[[:space:]]foo[[:space:]]' Will work. Or, if I'm reading the spec correctly: SELECT * FROM table WHERE field REGEXP '[[:space:][:punct:]]fo

Categories : Mysql

Applyng expression to ruby search and replace with regexp
Is this what you want? shopping_list = <<LIST 3 apples 500g flour 1 ham LIST new_list = shopping_list.gsub(/d+/m) do |m| m.to_i * 10 end puts new_list # >> 30 apples # >> 5000g flour # >> 10 ham Documentation: String#gsub.

Categories : Ruby

How to call query-replace-regexp inside a function?
When called from Lisp, query-replace-regexp expects to be passed regular expression and the intended replacement as arguments. If you want to emulate the questions asked when invoked interactively, you need to use call-interactively: (defun query-replace-regexp-whole-buffer () "query-replace-regexp from the beginning of the buffer." (interactive) (goto-char (point-min)) (call-interactively 'query-replace-regexp)) Also note that one should never call beginning-of-buffer from Lisp code; it will do unnecessary work, such as pushing the mark and printing a message.

Categories : Emacs

regexp to replace start/end symbols multiple times across the string
var str = '(q[1]="one" and q[2]="two")'; str = str.replace(/=("[^"]+")/g, '.indexOf($1)') this sets str to (q[1].indexOf("one") and q[2].indexOf("two"))

Categories : Javascript

Dynamic Javascript regexp to replace a string containing variable data
My own approach to this question would be to use a function to create, temporary, nodes from the HTML string and then parse those created nodes for the relevant information: function resourceTyping (htmlString) { var _tmp = document.createElement('div'), data = { html: htmlString, props : [] }; _tmp.innerHTML = htmlString; var children = _tmp.childNodes, rel, href, nodeHTML; for (var i = 0, len = children.length; i < len; i++) { rel = children[i].rel || ''; href = children[i].getAttribute('href') || ''; nodeHTML = children[i].outerHTML || ''; if (children[i].rel && children[i].href && nodeHTML.length) { data.props.push( { 'rel'

Categories : Javascript

Ruby regexp: why does this code not replace what is found but simply insert
That is because your intended capture www.google.com matches inside a lookahead (?=), so it is not actually captured. www.google.com only works as a lookahead context. What is captured is only an empty string at the position of match. sub is replacing the captured string (which is an empty string) with http://localhost:8080/el/133710.

Categories : Ruby On Rails

using regexp in visual studio 2010 to find and replace attributes
VS2010: Find What: {[cC]lass="[A-Za-z0-9_-]+ }popup{ [A-Za-z0-9_-]+"} Replace with: 1im-with-stupid2 Find options: Use Regular expressions VS2012: Find What: ([cC]lass="w+s)popup(sw+") Replace with: $1im-with-stupid$2 Find options: Use Regular expressions

Categories : Regex

Character set in Oracle 11g r2 XE
the table almost certainly has length semantics BYTE for the character columns. imp creates the table with the same length semantics as they were in the source database. So if you want to migrate to a multibyte character set you need to make sure that the length semantics of those columns are changed to character. Easiest is to pre-create the tables and make sure that your column definitions don't specify their length in bytes but in characters.

Categories : Oracle

How to replace (”); }); character
This does work correctly, may be you are using incorrect number of spaces. mysql> select REPLACE ( 'this is (”); });' , '(”); });','SPARTAAA!!!!'); +---------------------------------------------------------------+ | REPLACE ( 'this is (”); });' , '(”); });','SPARTAAA!!!!') | +---------------------------------------------------------------+ | this is SPARTAAA!!!! | +---------------------------------------------------------------+ In wordpress,it might be a case that the strings are stored as html entity (eg &quot; &lt;) instead of actual character,hence you are not able to replace it. I would suggest you to use this plugin : http://wordpress.org/plugins/search-and-replace/

Categories : Mysql

Replace more than one character! how?
If you want to replace every letter in a given string with another letter (for ease of use) without manually writing a lot of Replace every time, you could write something like this: String ReplaceChars(this string input, string chars, string replacement) { foreach (var c in chars) input = input.Replace(c.ToString(), replacement); return input; } Then you could write "abcdefgh".ReplaceChars("acd","x") and this should get you the string xbxxefgh.

Categories : Asp Net

Replace every other character
Capture the first character instead, and write it back: "abc123.-def45".gsub(/(.)./, '1@') It's important that you don't make the second character optional. Otherwise, in an odd-length string, the last character would lead to a match, and a @ would be appended. Without the ?, the last character will simply fail and remain untouched. Working demo.

Categories : Ruby

Oracle insert character into a string
You would try something like: Update Table_name set table_column = substr(table_column, 1, 3) || '_' || substr(table_column, 4); The SUBSTR functions allows you to extract a substring from a string. The syntax for the SUBSTR function is: SUBSTR( string, start_position, [ length ] ) string is the source string. start_position is the position for extraction. The first position in the string is always 1. length is optional. It is the number of characters to extract. If this parameter is omitted, the SUBSTR function will return the entire string.

Categories : Oracle

Replace character in std::string with hex value
You need to use the x escape sequence to represent hexadecimal characters. Moreover, since you're replacing just one character, you could use character literals rather than string literals: fileBuf.replace(0x10, 1, 'x44');

Categories : C++

Replace a character by another in a file
Truncate the file using file.truncate first: >>> f = open("foo", "a+") >>> f.write('a') >>> f.truncate(0) #truncates the file to 0 bytes >>> f.write('b') >>> f.seek(0) >>> f.read() 'b' Otherwise open the file in w+mode as suggested by @Guillaume.

Categories : Python

Replace the first character of each line
Global substitute the first character of a line if it is 'a': :%s/^[a]/!/ Global substitute the first character of a line if it is not space: :%s/^[^ ]/!/

Categories : Vim

How to replace the character I want in a line
Another way would be with zs and ze, which mark the beginning and end of a match in a pattern. So you could do: :%s/aaa.*zsaaaze/yyy In other words, find "aaa" followed by anything and then another "aaa", and replace that with "yyy". If you have three "aaa"s on a line, this won't work, though, and you should use {-} instead of *. (See :h non-greedy)

Categories : Vim

Replace character and words
I'd suggest, in this limited case: var text = 'ley orgánica 4/2013 28 junio reforma consejo general poder judicial modifica ley orgánica 6/1985 1 julio poder judicial', newText = text.replace(/([/0-9])/g, '');

Categories : Javascript

replace two same character with whitespace
If you're displaying the resulting string in an HTML element then two or more whitespaces will be displayed as only one whitespace. To workaround this fact, use &nbsp; instead: return str.replace(/*/g, '&nbsp;');

Categories : Javascript

Replace all special character except one
Use a negated character class... string = str.replaceAll("[^\w-]", " ") W is great for convenience, but when you need to add extra characters to your pool, you need to use a character class with w. The reason this doesn't work... string = str.replaceAll("\W[^-]", " ") ...is because it's scanning for non-word characters ([^A-Za-z0-9_]) followed by not a - character. For example, /A would be matched, but /- would not be.

Categories : Java

Replace character with linebreak
You should do this : $data = str_replace(";", "; ", $data); The str_replace functions returns a string, it does not modify the string passed in parameters. More info here: http://php.net/manual/fr/function.str-replace.php

Categories : PHP

Geting UTF-8 character issue in Oracle and Java
You need to specify useUnicode=true&characterEncoding=UTF-8 while getting the connection from the database. Also make sure the column supports UTF-8 encoding. Go through Oracle documentation.

Categories : Java

ORA-00911: invalid character in C#, but not Oracle SQL Developer
At a minimum, you don't want the trailing semicolon in the SQL statement you send from C#. I would strongly advocate as well that you use bind variables rather than concatenating together a string with your SQL statement. That will be more efficient, it will prevent shared pool related errors, it will make your DBA much happier, and it will protect you against SQL injection attacks.

Categories : C#

How can I replace all instances of the backslash character?
Try: Regex.Escape(mystring); See: Escape special characters in MySQL using C# and ASP.Net Example: var data = "this is a test"; var result = Regex.Escape(data); // this is a test //replace escaped spaces Console.Write(result.Replace(@" ", " ")); // this is a test

Categories : C#

Replace Everything After the 3rd Occurrence of a Character if Present
Without a Regex you can do it using simple string splits: function planReplace(str) { var split = str.split('/'); if (split.length < 2) return str; if (split[1] === 'plan') return "/" + split[1] + "/" + split[2]; //this line can even be shorter, but it would use a bit more memory: //if (split[1] === 'plan') return split.splice(0, 3).join('/'); return str; }

Categories : Javascript

Ideas for Find and Replace character
If the data is stored in MySQL, then it is better to process it there: UPDATE addresses SET address = CONCAT(LEFT(address, CHAR_LENGTH(address) - 1), UPPER(RIGHT(address, 1))) WHERE address REGEXP BINARY '#[[:digit:]]+[[:lower:]]{1}$' ; I've added BINARY because otherwise REGEXP is not case-sensitive, but BINARY may need to be omitted to support multi-byte strings. In this case, surplus updates will be made, but the result would be correct anyway. P. S. An example on SQL Fiddle showing which values are affected, and how they are affected: http://sqlfiddle.com/#!2/b29326/1

Categories : Mysql

Replace character and swap with the next one in string.
do the str_replace first, then use strlen, substr and the index of the character string to replace the last 2 spots if that is what you are trying to do. Because you can access a string like an array each characters $t[1] == e if the string was "test" If you have a few "set" patterns you could just do this: $find = array('RAVI',...,so on); $replace = array('raiv',..., so on); $input = 'RAVI'; echo str_replace($find, $replace, $input); Just add more set pairs to the arrays for more replacements... If that's all you want.

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.