w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Huge string replace in JavaScript?
I don't know much about speed in JavaScript, or why this can't be configured correctly on the server, but here's one way to do it. Interactive Demo First we turn everything into an object, so we can look up translations. var map = {}; for (var i=0; i<toReplace.length; i++) { map[toReplace[i]] = replaceWith[i]; } Then we join our keys into a regular expression (note: they must be sorted longest-first, code in the demo). var expression = new RegExp(toReplace.join("|"), "g"); In the replace function, we can subsitute matches for results. This is as simple as looking them up in our map. function doReplace(source) { return source.replace(expression, function(m) { return map[m]; }); } var result = doReplace("Señor");

Categories : Javascript

In NotePad++ find and replace, how would I use what I found in my replace?
Enclose it in parentheses in your find. request.POST[("[a-z A-Z _]*")] Then use 1 in your replace. That will return what was captured by the first set of parentheses. (Use 2, 3, etc. if you have multiple capturing groups.

Categories : Regex

Perl write to file returns huge weird stacktrace
The PK in file header it means it is compressed ZIP like file, like docx. One guess: The ; is not valid character in filename at the destination? Your regexp is not good: (the dot alone is applicable to any character...) $value =~ s/([^a-zA-Z0-9_-.]|;)/uc sprintf("%%%02x",ord($1))/eg; Try this: #replace evey non valid char to underscore $value =~ s/([^a-zA-Z0-9_-.;])/_/g;

Categories : Perl

Notepad++ How to replace everything in between certain lines
Regex is your friend. Ctrl-H (Find/replace) and enable regular expressions (bottom left of dialog). {s*}$ replace with: { whatever you want } Regex Match Explanation: {} are reserved, so escaping them will match the actual brace character s of course will match all whitespace (including new lines and tabs) $ would be the end of the line; this just helps the match in the replace would insert new lines where it makes sense; these are optional.

Categories : Regex

Notepad++ range replace
You might be able to leverage regular expressions. The range limitation makes it more difficult, but with 2 different replaces, I think we can manage it. (The complication comes from the fact you don't want to replace values like 900.4.3.) Back up your file, just to be safe. Open the Replace dialog, and change Search Mode to "Regular expression". Enter birth_date="[678]dd.d+.d+" in "Find what:". Enter birth_date="451.1.1" in "Replace with:" Press Replace All. Change "Find what:" to birth_date="900.1.1". Press Replace All. Then check to make sure it did what you wanted. A differencing tool might be helpful there. (You can compare the modified file with the back up.) The two different regexes are necessary because of the range. The first one catches anything starting with 6, 7, or 8 plu

Categories : Python

Regular expression for Notepad++ to replace this?
I believe this should work: [0-9]+</td><tdswidth="8%">2 If you editor supports groupped editing, use paranthesis to mark each group then edit the one you need. Groupped version: ([0-9]+)(</td><tdswidth="8%">)(2)

Categories : Regex

Using Regex in Notepad++ to Replace a Character
There are two options. You could use capturing and write back what you matched (in addition to the quotes): ([a-zA-Z0-9]{16},)([a-zA-Z]+) Each set of parentheses generates a captured group. You can reference what they matched with $n in the replacement string: $1"$2. Note that there is no need to escape the comma. The alternative is lookarounds. What you match inside a lookaround is not part of the match, so it doesn't get removed. If you put everything around the desired position in lookarounds, you'll match a position instead of a string, and the replacement string will simply be inserted in that position: (?<=[a-zA-Z0-9]{16},)(?=[a-zA-Z]+) And replace that with ". In any case, make sure to upgrade to Notepad++ 6. Finally note that in both cases the + at the end is irreleva

Categories : Regex

Notepad++find/replace regex
I think something like this should work. It's not tested, though. Find: ^d{5}) + d{4}:d pushstring "(.*)"$ Replace: http://static-0.farmville.zgncdn.com/1

Categories : Misc

Notepad++ v6.3.2 backreference regex replace not working
You must understand that $n refer to the capturing group number n. Since you don't have capturing groups in your search pattern, the group number 1 doesn't exist: You must use capturing parenthesis to define a group, example: search: (&lt;header) replace: $1 class="bold" Another example: search: (&lt;)(header) replace: $1$2 class="bold" Notice: $0 refers to the whole match (without define any capturing group). Then you can write: search: &lt;header replace: $0 class="bold"

Categories : Regex

How to use regex to replace text between tags in Notepad++
A regular expression to return "the thing between <pre><code> and </code></pre>" could be /(?<=<pre><code>).*?(?=</code></pre>)/ This uses lookaround expressions to delimit the "thing that gets matched". Typically using regex in situations with nested tags is fraught with danger and you are much better off using "real tools" made specifically for the job of parsing xml, html etc. I am a huge fan of Beautiful Soup (Python) myself. Not familiar with Notepad++, so not sure if its dialect of regex matches this expression exactly.

Categories : Regex

Mass Replace differetent word using notepad ++
Search for <esi:include src=([^/]*)/> and replace with <!--#include virtual=$1--> You can capture parts you want to reuse by putting round brackets around, that is called a capturing group. You can then insert them in the replacement string by adding $x, where x is the number of the capturing group. The groups are numbered by the opening brackets.

Categories : Regex

How to store regex match in a variable to use with Search/Replace in Notepad++
Yes, $& or $0 represents the entire match in the replacement string: Find what: .*?(?=[ ]) Replace with: INSERT INTO table (value) VALUES ("$0") Note that you don't need the quotes inside the character class. Otherwise your match will stop at a quote as well. Also note, that there is another catch, that you have to escape parentheses in the replacement string (thanks to acdcjunior for noticing that). That's because Notepad++ uses boost, which supports a parenthesis-delimited conditional construct. Using your input, this will result in INSERT INTO table (value) VALUES ("ab") iiids INSERT INTO table (value) VALUES ("as") sasas INSERT INTO table (value) VALUES ("md") aisjaij INSERT INTO table (value) VALUES ("as") asijasija For more advanced use cases, you can wrap parts of the reg

Categories : Regex

Conditional statement for find and replace in Notepad++ or any text editor
You can do that using Regular Expressions. Use the regex below at the Find what: field: <Coverage>s*(1[0-4]|[0-9])?[0-9]?[0-9]?[0-9]?[0-9]s*</Coverage> And Replace with: <Coverage>150000</Coverage> This will replace every <Coverage>number</Coverage> string where the number is smaller than 150000. Check this online demo. The blue text is what will be matched and replaced. Do some tests, write some examples and make sure it matches what you expect. Usage on Notepad++: Make sure you check the Regular Expression radio in the Search mode box. Check an example below.

Categories : Xml

Notepad++ regex - howto replace all underscores, which follow a = sign?
Make a find of: (=[A-Za-z]*)_ And replace it with: $1 [Note: there is a space after the $1] Be sure to check the 'Regular expression' mode, and click replace all. Sometimes, you need to select all first (when your cursor is at the end and you have 'Find Down' checked for instance) I'm assuming there are only alphabets between the equal sign and the underscore you want to remove.

Categories : Regex

How to replace NaN value with zero in a huge data frame?
The following should do what you want: x <- data.frame(X1=sample(c(1:3,NaN), 200, replace=TRUE), X2=sample(c(4:6,NaN), 200, replace=TRUE)) head(x) x <- replace(x, is.na(x), 0) head(x)

Categories : R

regex - notepad++ - search for a string containing a string and not containing another string
Try using negative look ahead: user = (?![aA][bB]).* You are misunderstand how a character class works. The character class - [ab] matches only one character, out of all present inside [ and ]. So, it will match either a or b. I won't match ab in sequence. Basically [ab] is same as a|b.

Categories : Regex

How to replace word in notepad++ that begins with certain word plus number of bytes
2013d{10} will match 2013 and 10 digits after it. UPD: Here's a slightly improved version of the regex: 2013[0,1][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9] that will still match, for example, 20130601000000 because it's a valid timestamp.

Categories : Regex

How to prevent or replace weird characters in pasted Vim macros
You could use a simple function like this to substitute each occurrence (on the current line) of ^M, ^[, etc. with their replacements. You can add extra entries to the replacements dictionary as you find you need them. function! ReplaceWeirdCharacters() let replacements = { "<C-[>": '<Esc>', "<C-M>": '<CR>', "u80kb": '<BS>' } for [a, b] in items(replacements) execute "s/" . a . "/" . b . "/ge" endfor endfunction nnoremap <leader>rwc :call ReplaceWeirdCharacters()<CR>

Categories : Vim

Boost String Replace Doesn't Replace Newline With String
std::getline doesn't read newline characters when it extracts from the stream and so they're newer written in fileContents. Also, you don't need to search and replace " ", streams abstract this away and translate them to ' '.

Categories : C++

Find and replace duplicates in Array, but replace each nth instance with a different string
EDIT Counter and than sorting is simpler: L = ['champ', 'king', 'king', 'mak', 'mak', 'mak'] counts = Counter(L) res = [] for word in sorted(counts.keys()): if counts[word] == 1: res.append(word) else: res.extend(['{}{}'.format(word, index) for index in range(1, counts[word] + 1)]) So this ['champ', 'mak', 'king', 'king', 'mak', 'mak'] also gives: ['champ', 'king1', 'king2', 'mak1', 'mak2', 'mak3']

Categories : Python

Javascript: using String.replace() to replace/remove HTML anchors
All of the anchors are stored in an array (['about','contact'],...), and I need to remove every occurance of a string like href="#whatever" (where whatever is each time something different) so that the result is for this you could do something like this: var tets_array = $("a[href^='#']"); // select all a tags having href attr starting with # Then take the array and modify with what you want.

Categories : Javascript

Jquery Ajax - post huge string value
You will need to use a POST request: $.ajax({ url: '/script.php', type: 'POST', data: { value: 'some huge string here' }, success: function(result) { alert('the request was successfully sent to the server'); } }); and in your server side script retrieve the value: $_POST["value"] Also you might need to increase the allowed request size. For example in your .htaccess file or in your php.ini you could set the post_max_size value: #set max post size php_value post_max_size 20M

Categories : Javascript

Java print a huge string array as it is
There's nothing in the standard API for this. There are several third-party packages that have a "join" method that does what you want (and then some). A particularly nice one is Guava's Joiner. (Per Tim's comment, the StringUtils.join() method in the Apache Commons Lang library also does everything you need.) Using a good third-party library can make a lot of these coding problems go away. If you don't want (or are not allowed) to use a third-party library, you can write a method to concatenate the elements using the delimiter of your choice: public static String join(String[] data, String delimiter) { StringBuilder sb = new StringBuilder(); if (data != null && data.length > 0) { for (String item : data) { sb.append(String.valueOf(item);

Categories : Java

String replace: multiple replace is not working in JQuery
Use global replace with "g" flag: /reg_ex_here/g or new RegExp(exp, 'g') var string = 'bla bla bla'; string.replace(/bla/g, 'ok'); // -> ok ok ok string.replace(new RegExp('bla', 'g'), 'ok'); // -> ok ok ok In your code: var replace_str = 'options\[team_member\]\['+(current-1)+'\]'; rep_block = block.replace(new RegExp(replace_str, 'g'), replace_with);

Categories : Javascript

Reading text file to string without huge memory consumption
Try Apache Commons IO: http://commons.apache.org/proper/commons-io/ I didn't benchmark it but I think the code is optimised.

Categories : Java

MS Outlook 2010 .SenderEmailAddress returns a huge string of characters
This is a perfectly valid EX type address (as opposed to SMTP). Try to use MailItem.Sender.GetExchangeUser().PrimarySmtpAddress. You will need to check for nulls/errors of course in case the sender is not an Exchange user or if the address cannot be retrieved.

Categories : Misc

java. is there any google's guava interface to replace Map>?
Yes, it's called Table: A collection that associates an ordered pair of keys, called a row key and a column key, with a single value. A table may be sparse, with only a small fraction of row key / column key pairs possessing a corresponding value. The mappings corresponding to a given row key may be viewed as a Map whose keys are the columns. The reverse is also available, associating a column with a row key / value map. Note that, in some implementations, data access by column key may have fewer supported operations or worse performance than data access by row key. There are few implementations: ArrayTable (backed by two-dimentional array, see the documentation), ForwardingTable (implements decorator pattern), HashBasedTable (~ HashMap<R, HashMap<C, V>),

Categories : Java

Weird colors in background of UIImage when trying to replace all white colors
Using a different code I slipped in my loop and it no longer showed the random background static: -(UIImage *)replaceWhiteWith{ NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"color"]; UIColor *color = [NSString colorFromNSString:str]; CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha =0.0; [color getRed:&red green:&green blue:&blue alpha:&alpha]; CGImageRef inImage = self.CGImage; CFDataRef ref = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); UInt8 * buf = (UInt8 *) CFDataGetBytePtr(ref); int length = CFDataGetLength(ref); for(int i=0; i<length; i+=4) { int r = buf[i]; int g = buf[i+1]; int b = buf[i+2]; if(r == 255 && g == 255 && b == 255){

Categories : IOS

c++ weird string size
You guess is right. The problem is that you forgot to set result[count]=0 . Therefore your code has undefined behavior because the char array result is not terminated by ''. After you add result[count] = 0; before found = ..., you will get the same results for both sample A and sample B.

Categories : C++

Weird $ behavior: ${string}
The bareword "string" is being understood as a string you simply didn't quote. use strict would prohibit this, and use warnings would have complained about it. You are then taking a reference to the string (effectively, my $ref = "string";), and dereferencing it (effectively, ${$ref}). It is "normal" in the sense that life without strict is sometimes both slippery and sharp-edged.

Categories : Perl

Rails returns a weird string
From the documentation Be careful because this also means you're initializing a model object with only the fields that you've selected. So using select still creates a model object. You need to use something like current_schedule_record = { 'driver_name' => Driver.where(['id = ?', id]).select('first_name').first.first_name }

Categories : Ruby On Rails

Extracting numbers from weird version string
By using a combination of masks and shifts: int main() { const uint32_t v = 0x00870016; const uint16_t major = (v & 0xFFFF0000) >> 16; const uint16_t minor = v & 0x0000FFFF; cout << major << "." << minor << " "; } Output: 135.22 Explanation: 0x00870016 is a 32-bit number. Your major version number is composed from the 16 most-signifigant digits, and the minor version number is the 16 least-signifigant digits. In order to extract the major version number, let's find out that the 16 MSBits are by masking the input value with 0xFFFF0000 -- a number where all 16 of the most-signifigant digits are set to 1 and all the least-sig bits are 0: 0x00870016 && 0xFFFF0000 = 0x00870000 The resulting value is your major version nu

Categories : C++

How to replace percentage value to replace with some string value in percentage specific 2d horizontal fusion charts
give numbersuffix='%25' to display '%' as suffix sample : http://www.fusioncharts.com/free/docs/Contents/Adv_SpChar_Percent.html

Categories : Misc

BASH: filter huge list of numbers if they are contained in another huge list
I'm not sure about a solution in pure bash, but i can provide one using awk: awk -F"," 'NR==FNR{col3[$2]++;next;}{ if ($1 in col3 && $2 in col3) print $0} ' File1 File2 First read the 2nd column of the first file into an associative array and then look for each row of the second file wether they are in the array or not.

Categories : Bash

get specific string after first occurance of string regex sublime text 2 find & replace
I don't know that sublimetext2 but the regular expression would look like this: /include_once($pathToRoot.'header.php');(.*?)(</div>)/s The first group would be the string between the include and the closing div and the second group would be the closing div itself.

Categories : Regex

Replace letters in string with the next letter, and capitalize vowels in the changed string
There are several issues. The main one is that you could inadvertently change the same letter several times. Let's see what happens to the s in sent. You first change it to t. However, when it comes to changing the final letter, which is also t, you change the first letter again, this time from t to u. Another, smaller, issue is the handling of the letter z. Finally, your indexing in the second if is off by one: d becomes D and not E.

Categories : Javascript

String Split/ String replace based on character length
You could do this: declare l_in_string varchar2(1000) := 'hi hello how are you doing out there, need your help!'; l_out_string varchar2(1000); begin while length(l_in_string) > 35 loop l_out_string := l_out_string || substr(l_in_string, 1, 35) || '<br>'; l_in_string := substr(l_in_string, 36); end loop; l_out_string := l_out_string || l_in_string; dbms_output.put_line(l_out_string); end; However this is quite likely to break mid-word e.g. hi hello how are you doing out there, need your help! You would need to write more sophisticated code if you want to break on spaces only.

Categories : SQL

How Replace Hidden (Strange) Characters From A String With string.Empty
Remove all non-printables: var str = "kljdfssdflksdfklx03kdkddkx04lkdldök"; var onlyPrintableChars = str.Where(ch => !char.IsControl(ch)).ToArray(); var resultStr = new string(onlyPrintableChars);

Categories : C#

How to Replace CSV String in LINQ Query , Wanted to Replace CSV with NewLine in LINQ
Html does not recognize new lines as actual line breaks when rendered. Instead try this: var query = (from r in objEntities.Student select new { FullName = r.FullName.Replace(",", "<br />") }).ToList();

Categories : String

Javascript regular expression weird behavior String.match()
#? matches at every position in the string, as empty strings are still considered matches. . matches #? before it can match . and you end up with a result of empty strings and a hash if there is one. If you're trying to parse CSS selectors, don't use regex. Just write your own parser.

Categories : Javascript



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