w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
MS Word VBA - Finding a word and changing its style
I believe the reason why your macro isn't finding the words is due to the presence of leading or trailing blank spaces. Providing that you have already defined the style "NewStyle" changing your if statement in SubFnR2 from If IsInArray(rng, mykeywords(nKey)) Then to If mykeywords(nkey) = LCase(Trim(rng.Text)) Then Should solve the issue. By the way if you want to keep the style of the word depending on whether it is upper or lower case then remove the LCase part. Edit: I have included the sub with the modification below. I have tested it on the examples you gave (cut and pasted into word) and it changed the style for both instances word1. Sub FnR3() Dim rng As Range Dim mykeywords mykeywords = Array("word1", "word2", "word3") Dim nkey As Integer For nkey = LBound(mykeywords) To

Categories : Vba

Replacing all occurrences of a word with another
You don't need regex here, and neither Pattern and Matcher classes. Simple use of String.replace() will work fine: input = input.replace("japan", "Japan");

Categories : Java

QT: Finding and replacing text in a file
If the required change, for example is to replace the 'ou' with the american 'o' such that "colour behaviour flavour neighbour" becomes "color behavior flavor neighbor", you could do something like this: - QByteArray fileData; QFile file(fileName); file.open(stderr, QIODevice::ReadWrite); // open for read and write fileData = file.readAll(); // read all the data into the byte array QString text(fileData); // add to text string for easy string replace text.replace(QString("ou"), QString("o")); // replace text in string file.seek(0); // go to the beginning of the file file.write(text.toUtf8()); // write the new text back to the file file.close(); // close the file handle. I haven't compiled this, so there may be errors in the code, but it gives you the outline and general idea of what

Categories : C++

Apache POI Word .DOC Replacing Text
This presents the alternatives. It is in the context of docx4j, but the options also apply in principle to POI.

Categories : Apache

Replacing comma with & before the last word in string
Here's my take on this, using array_pop(): $str = "A, B, C, D, E"; $components = explode(", ", $str); if (count($components) <= 1) { //If there's only one word, and no commas or whatever. echo $str; die(); //You don't have to *die* here, just stop the rest of the following from executing. } $last = array_pop($components); //This will remove the last element from the array, then put it in the $last variable. echo implode(", ", $components) . " &amp; " . $last;

Categories : PHP

Replacing one specific word in the textarea
As mentioned in my comment, you could replace the very last word, that is most probably the one you're currently typing. Or you can take a look here and see how to get the current cursor position. You'll have the exact word to replace afterwards.

Categories : Javascript

Finding and replacing multiple URLs in one line
Replace your if statement with this : if(eElement.getAttribute("shorturl") != null) { String findShortURL= eElement.getTextContent(); originalMessage = originalMessage.replaceAll(URLget, findShortURL); System.out.println(originalMessage); } Use println outside the for loop to get it to give you the output just once.

Categories : Java

replacing one word by another in an entire directory - unix
You probably have perl installed (if its UNIX), so here's something that should work for you: perl -e "s/Foo/Bar/g;" -pi.save $(find path/to/DIRECTORY -type f) Note, this provides a backup of the original file, if you need that as a bit of insurance. Otherwise, you can do what @Kevin mentioned and just use an IDE refactoring feature. Note: I just saw you're using Vim, here's a quick tutorial on how to do it

Categories : Regex

replacing occurences of a word with another on the first line of a text in PHP
You can load only first line to variable, than do str_ireplace and then put first line + rest of the file back together. $data = explode(" ", $string); $data[0] = str_ireplace("%title%", "TITLE", $data[0]); $string = implode(" ", $data); Its not the most efficient way imho, but suitable and fast to code.

Categories : PHP

finding and replacing text in a access table column
It works in VBA but in SQL you may need to use the WHERE clause; that is, not attempting to use Replace() if the text is not found. Update table set column = Replace(column, 'some text', 'new data') WHERE column Like '*some text*' I haven't had a chance to test this though. It might also be worth putting square brackets around the field-name Replace([column],, although this shouldn't really be necessary. Added As you've discovered, you cannot use Replace from C#. You can use other functions - Left, Right, Mid, Trim - but this won't help unless it were a very simple replace (perhaps from the left). Otherwise, you'll need to obtain and loop through an updateable RecordSet and perform the replace in C#. Alternatively, if you have access to the database from within Access, then you coul

Categories : SQL

Need help mass finding/replacing portions of a text file
Assuming you have a root to this xml, you could do something like the following by loading the xml as $xml_string: $xml = new SimpleXMLElement($xml_string); foreach($xml->children() as $child){ $child->id = $child->filename; } $xml->asXml('updated.xml');

Categories : PHP

RegEx - Finding Text Between Quotes and Replacing Between Parentheses
you can use notepad++ macro instead of regex. place your crusor on your second line, press home then click menu macro > start recording, then do the following steps : ctrl+right_arrow(until your number, three time maybe) ctrl+shift+right_arrow ctrl+c(copy) up_arrow home ctrl+right_arrow(until your number, three time maybe) ctrl+shift+right_arrow ctrl+v(paste) then stop recording, and pres run macro multiple times > until the end of file > run

Categories : Regex

Given a 2D matrix of characters we have to check whether the given word exist in it or not
In fact you have 16 sequences here: sft dah ryo sdr fay tho sao rat tfs had oyr rds yaf oht oas tar (3 horizontal + 3 vertical + 2 diagonals) * 2 (reversed) = 16. Let n be a size of a matrix. In your example n = 3. Number of sequences = (n + n + 2) * 2 = 4n + 4. Now you need to determine whether a sequence is a word or not. Create a hash set (unordered_set in C++, HashSet in Java) with words from dictionary (found on the internet). You can check one sequence in O(1).

Categories : C++

C# Interop.Word 2013 replacing substring format MULTIPLE TIMES within one line
you need to use for loop.. here is code : int i = 0; int index = text.IndexOf("color", i); while (index > 0) { object oStart = parag.Range.Start + index; object oEnd = parag.Range.Start + index + 4; Range subRange = doc.Range(oStart, oEnd); subRange.Bold = 1; i = index + 4; index = text.IndexOf("color", i); } try this out.......

Categories : C#

VBS exit loop where no more track changes exist in word document
It is a bit unclear which revision elements you really need to track as far as you use WordBasic.NextChangeOrComment instruction. However, assuming that you need to track revisions but not comments you could insert the code below right after the comment you put to your Sub: '<exit loop if there is no more track changes and not at last page> With ActiveDocument.Content.Revisions If Selection.Range = .Item(.Count).Range Then 'MsgBox "Last one" - for test only Exit Do End If End With If you need to trace comments to you need to create similar solution as for revision items (Comments collection doesn't include Revisions collection and vice-versa).

Categories : Vba

Finding next word after a string
You can do this: string text = "Control Number: 123foobar"; var match = Regex.Match(text, @"c[o0]ntr[o0][l1i]s+nu(?:in|m)ber[:;s]s*(w*)", RegexOptions.IgnoreCase); if (match.Success) { var controlNum = match.Groups[1].Value; // 123foobar }

Categories : C#

Two update queries with Exist reserved word Microsoft Access
My guess is you want to extract the first and last names from the full name field and store them in the same row. UPDATE Employee_Table SET First_Name = Left(Full_Name, InStr(Full_Name, " ") - 1), Last_Name = Mid(Full_Name, InStr(Full_Name, " ") + 1) WHERE First_Name Is Null AND Last_Name Is Null;

Categories : SQL

Python: Finding the word that shows up the most?
I think you may want to do: for word in textInput.split(): ... Currently, you are just iterating through every character in the textInput. So to iterate through every word, we must first split the string up into an array of words. By default .split() splits on whitespace, but you can change this by just passing a delimeter to split(). Also, you need to check if the word is in your dictionary, not in your original string. So try: if word in word_counter: ... Then, to find the entry with the highest occurrences: highest_word = "" highest_value = 0 for k,v in word_counter.items(): if v > highest_value: highest_value = v highest_word = k Then, just print out the value of highest_word and highest_value. To keep track of ties, just keep a list of the highest wo

Categories : Python

Finding first word after regex match
Use capturing groups: (Car|Truck|Van):s*(w+) Now .group(1) will return Car and .group(2) will return Chevy. String input = "I have the following Car: Chevy, Truck: Ford, Van: Honda"; Pattern p = Pattern.compile("(Car|Truck|Van):\s*(\w+)"); Matcher m = p.matcher(input); while (m.find()) { System.out.println(m.group(1) + " " + m.group(2)); } Car Chevy Truck Ford Van Honda

Categories : Java

Finding the occurance of seeing word A followed by everything but B using preg_match in PHP
$text = 'Hello world, Hello Bye, Hello Andy, Hello'; // initialize counters first $count_hellos = $count_hello_byes = $count_hello_no_byes = 0; // look for Hello - Bye if(preg_match_all('~\bHello\b~si', $text, $matches)){ $count_hellos = count($matches[0]); unset($matches); } // look for Hello + Bye if(preg_match_all('~Hello\W+Bye~si', $text, $matches)){ $count_hello_byes = count($matches[0]); unset($matches); } // do the math $count_hello_no_byes = $count_hellos - $count_hello_byes; var_dump($count_hello_no_byes); // what you are looking for ^ easily achievable like this! LEARN MORE HERE about RegEx Shorthand character classes.

Categories : PHP

Search txt file not finding full word
Your question indeed is sort of stupid (no offence please) because what you have there just works: <?php $text = <<<BUFFER Breanna says hello Joe says hello Steven says hello Lyn says hello Len says hello James says hello BUFFER; $lines = explode(" ", $text); $lines_two = preg_grep("/James/", $lines); foreach($lines_two as $name){ echo "$name "; } Demo: https://eval.in/private/f5bdf0fdfdb55d ; Program Output: James says hello So about whatever / wherever you think the problem is, you do not ask about it specifically. The information given does not allow to reproduce your problem. I just copy and pasted this from your question.

Categories : PHP

C# finding the shortest and longest word in a array
Your for loop condition is always false. i starts at 5 and you are checking for it to be less than 0... This is always false so the loop never starts. And if that is just a typo, you are also putting the input into names[i] instead of word[i], and names[i] is never used again...

Categories : C#

Finding occurrences of a word in a string in python 3
Use a list comprehension: >>> word = "dog" >>> str1 = "the dogs barked" >>> sum(i == word for word in str1.split()) 0 >>> word = 'dog' >>> str1 = 'the dog barked' >>> sum(i == word for word in str1.split()) 1 split() returns a list of all the words in a sentence. Then we use a list comprehension to count how many times the word appears in a sentence.

Categories : Python

What is the best Algorithm for finding word sequence frequency in a stream
I think you would be better using some sort of map or hash table of triples, because then you store only triples that actually occur, whereas with an array you make space for all possible triples. If you see n words, they might all be different, in which case you store about n triples - but an array for all triples of n different words would be of size n^3. As a curiosity, there are bijective maps from pairs of non-negative integers to non-negative integers. One such is (a,b)->(a+b)(a+b+1)/2 + b which maps (0, 0) (0, 1) (1, 0) (0, 2) (1, 1) (2,1) ... to 0, 1, 2, 3, 4, 5, .. - think of it as numbering the pairs by writing them out in a square and then numbering down diagonals. You could use this twice to map triples of numbers to a single number: (a, b, c) -> ((a, b), c). However it isn't

Categories : C++

Finding the number of ways a word can be permuted in java
You don't use the letters outside the scope of the loop, nor together, so you could have just used a single variable String word; int result; int cases; int lengthOfWord; for(int iteration = 1;iteration <= cases; iteration++) { word = br.readLine(); lengthOfWord = word.length(); result = factorial(lengthOfWord); for (int i = 0; i < letters.length; i++) { int divisor = lengthOfWord - word.replace(((char)((int)'A' + i)).toString(), "").length(); result /= divisor; } System.out.printf("Data set %d: %d ", iteration, result);

Categories : Java

Finding a word after specific string - sql management studio 2012
The code you are looking for should first look for the string Action and then for a space character after that word. After that you have all you need to manipulate your source string. This should work: DECLARE @P_string nvarchar (100), @P_variable nvarchar (100), @idx1 int, @idx2 int SET @p_string = 'hello Action=Refer non-action=non-refer' SET @p_variable = 'Action' SELECT @idx1 = charindex(lower(@P_variable),lower(@P_string)) + len(@p_variable) + 1, @idx2 = charindex(lower(' '), @P_string, @idx1) SELECT @idx1, @idx2 SELECT SUBSTRING( @p_string, @idx1, @idx2 - @idx1) as trying EDIT After more thoroughly reviewing the requirements, I decided to tailor a rCTE structure that I use for similar purposes. Here it goes. CREATE TABLE #retention1 ( ID int, txt nv

Categories : Sql Server

Finding the pattern and replacing the pattern inside the file using unix
Try using sed. #!/bin/bash # The input file is a command line argument. input_file="${1}" # The map of variables to their values declare -A value_map=( [abc]=ddd [ccc]=10 ) # Loop over the keys in our map. for variable in "${!value_map[@]}" ; do echo "Replacing ${variable} with ${value_map[${variable}]} in ${input_file}..." sed -i "s|${variable}|${value_map[${variable}]}|g" "${input_file}" done This simple bash script will replace abc with ddd and ccc with 10 in the given file. Here is an example of it working on a simple file: $ cat file.txt so boo aaa abc duh abc ccc abcccc hmm $ ./replace.sh file.txt Replacing abc with ddd in file.txt... Replacing ccc with 10 in file.txt... $ cat file.txt so boo aaa ddd duh ddd 10 ddd10 hmm

Categories : Linux

I want to find the word and replace the 3 word after the search string with my desired word in batch script
You were close. See mods to your code below. If you really want the first word after wordB... this will do it. Don't enable delayed expansion if you don't need it because that just messes you up if there are ! in the text. @echo off SET InFile=test.txt FOR /F "tokens=*" %%A IN ('FINDSTR "wordA" "%InFile%" ^| FINDSTR "wordB"') DO CALL :FindString "%%A" pause goto :eof :FindString SET String=%~1 SET String=%String:*wordA =% SET String=%String:wordB =% FOR /F "tokens=1" %%A IN ('echo.%String%') DO ECHO.%%A :goto :eof

Categories : Batch File

Excel 2007 VBA MATCH function is not finding a match, but a match does exist in that range?
You must use MatchType of 0 to use wild card characters (* or ?) see: http://office.microsoft.com/en-001/excel-help/match-function-HP010062414.aspx Use Application.Match("More items related to*", Range("AZ1:AZ1000"), 0)

Categories : Excel

How to loop a MS Word macro applying word by word in a selection?
You can do something like this: Dim myRangeIndex As Range Dim myRangeStart As Range Set myRangeStart = Selection.Range For Each myRangeIndex In myRangeStart.Words() myRangeIndex.Select Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.TypeText Text:="a" Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Font.Color = -603914241 Selection.Font.Size = 1 Selection.MoveRight Unit:=wdWord, Count:=1 Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.MoveRight Unit:=wdWord, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.TypeText Text:="a" Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Font.Color = -603914241 Selection.Font.Size = 1 Selection.MoveRight Unit:=wdCharacter, Count

Categories : Vba

Is there any way to change word to another word depends on the condition inside the word?
Not sure exactly what you are after, but here is something: var startvalue = 0; if(MINVALUE > 0) { startvalue = MINVALUE; } Else if(MINVALUE < 0) { startvalue = MAXVALUE; } var result = String.Format(@"CREATE SEQUENCE ""MY_TEST_SEQUENCE"" MINVALUE 8 MAXVALUE 999 INCREMENT BY 1 START WITH {0} CACHE 20 NOORDER NOCYCLE",startvalue) Some more clarification of your question would allow for more useful answers.

Categories : C#

java: finding char offset, para offset of a word in a text file from the starting of the file?
If you are not parsing an XML file and only want the "offsets" for a given word regardless of the format of the file, AND you have enough memory to store the file in a String, try using Patterns: Pattern findWordPattern = Pattern.compile("his"); Matcher matcher = findWordPattern.matcher(myWholeFileInAString); while(matcher.find()) { int offsetStart = matcher.start(); int offsetEnd = matcher.end(); // do something with offsetStart and offsetEnd }

Categories : Java

replacing a character without replacing anything within ' ' in a string
I would go for a function like splitStr = str.split("'"); for(var i = 0; i < splitStr.length; i=i+2){ splitStr[i].replace(/s/g, "p"); } str = splitStr.join("'");

Categories : Javascript

InnoDB table errors: Doesn't exist/exist. Orphaned tables? Invisible database in mysql command clients
Ok nevermind. I finally fixed it. After adding the lines [mysqld] innodb_file_per_table to my.cnf, I dropped the whole database. Of course I dumped it earlier and recreated + restored the database. No problems here.

Categories : Mysql

Update if exist, insert row if not exist in MySQL
Try with ON DUPLICATE KEY like $sql = "INSERT INTO `table2` (Col2, Col3) VALUES ('val1', 'val2') ON DUPLICATE KEY UPDATE Col2='val1', Col3='val2'"; EDIT : INSERT INTO table2 (ColB , ColC) (SELECT ColB.b,ColC.b FROM table1 b LEFT JOIN table3 c ON c.IDA = b.IDA LEFT JOIN table2 a ON a.IDB = c.IDB WHERE IDB = 111 ) ON DUPLICATE KEY UPDATE ColB = ColB.b ColC = ColC.b And Try to avoid mysql_* statements due to the entire ext/mysql PHP extension, which provides all functions named with the prefix mysql_*, is officially deprecated as of PHP v5.5.0 and will be removed in the future. There are two other MySQL extensions that you can better Use: MySQLi and PDO_MySQL, either of which can be used instead of ext/mysql.

Categories : PHP

Preg_match find word after a word and after another word
if (preg_match_all('/classs?=s?"gametitles+(w+)"><[^>]+>s?(w+)/', $text, $matches)){ $word1 = $matches[1][0]; $word2 = $matches[2][0]; } Or with preg_match: if (preg_match('/classs?=s?"gametitles+(w+)"><[^>]+>s?(w+)/', $text, $matches)){ $word1 = $matches[1]; $word2 = $matches[2]; }

Categories : PHP

SQL SERVER 2012 IF EXIST and IF NOT EXIST
SQL Server has MERGE http://msdn.microsoft.com/en-us/library/bb522522(v=sql.105).aspx that you can use as an UPSERT. Here's an example copied from the docs (Example A): MERGE dbo.FactBuyingHabits AS Target USING (SELECT CustomerID, ProductID, PurchaseDate FROM dbo.Purchases) AS Source ON (Target.ProductID = Source.ProductID AND Target.CustomerID = Source.CustomerID) WHEN MATCHED THEN UPDATE SET Target.LastPurchaseDate = Source.PurchaseDate WHEN NOT MATCHED BY TARGET THEN INSERT (CustomerID, ProductID, LastPurchaseDate) VALUES (Source.CustomerID, Source.ProductID, Source.PurchaseDate) OUTPUT $action, Inserted.*, Deleted.*;

Categories : Mysql

How do I create and email by taking the adresses from word and having the word as an attachment using visual basic?
This is the function I've used in the past to do it with notes. Doesn't require passwords etc to be typed afaik. Sub SendNotesMail(Subject As String, Attachment As String, Recipient As Variant, BodyText As String, SaveIt As Boolean) 'Public Sub SendNotesMail(Subject as string, attachment as string, 'recipient as string, bodytext as string,saveit as Boolean) 'This public sub will send a mail and attachment if neccessary to the 'recipient including the body text. 'Requires that notes client is installed on the system. 'Set up the objects required for Automation into lotus notes Dim Maildb As Object 'The mail database Dim UserName As String 'The current users notes name Dim MailDbName As String 'THe current users notes mail database name Dim MailDoc As Object 'The mail docum

Categories : Vba

What rules/declarations do I need to add to a CSS class to enable word wrap with no single-word truncation?
As far as I'm aware you can't do this. max-width does its job. It will not let you exceed the bounds you set. You have the choice of breaking your word (word-wrap: break-word;), setting a larger max-width, or falling back to JQuery/Javascript to define your custom rules.

Categories : HTML

Check if a string starts with the a specific word, if True then print word - PYTHON
You can use str.startswith(): for word in SideMember: if word.startswith('Base'): print word It does exactly as you would expect it to do ;). By the way, you should only use capitalised variable names for classes. Some other methods you probably shouldn't consider, but for the fun of it I included them :p import re for word in sidemembers: if re.search(r'^Base', word) is not None: print word for word in sidemembers: if word[:4] == 'Base': print word

Categories : Python



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