w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

String Split sql function only returning first word in string
Your function is returning a leading blank in front of Andy. You should use LTRIM function to remove it. Either in function, on insert into @tbl: INSERT @tbl (string) VALUES (LTRIM (substring(@list, @pos + 1, @valuelen))) or when you call function: SELECT LTRIM(string) FROM [dbo].[func_ParseString] ('Dan, Andy')

Categories : SQL

how do you multiply word-size inputs and get its word-size product in stack?
You need to use 16-bit registers in all places where you're calculating the result: mov cx, [ebp+4] ; cx instead of cl mov [ebp+6], cx ; cx instead of cl ... mov [ebp+8], ax ; ax instead of al while: dec word [ebp+6] mov ax, [ebp+8] ; ax instead of al mov dx, 0 mul word [ebp+6] The code works for me with those changes (giving 6 as input gave me 720 as output).

Categories : Assembly

$subject in php mail form returning only first word in string
The HTML interpreter in the mail program is looking at the input elements and seeing the value attribute followed by a single unquoted word. Then it sees a bunch of other attributes without values. Quote the value properly in the first place. And sanitize too; you don't want your clients being hacked because of an email that was sent from your system.

Categories : PHP

strstr to find a word in a string using c returning true all the time
Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1. Returning NULL (0) essentially means that the string was NOT found. Thus if(strstr(sentence,word) == 0){ printf("word found!"); } Should be if(strstr(sentence,word) != NULL){ printf("word found!"); } Source - http://en.cppreference.com/w/c/string/byte/strstr Additionally as Armin points out, you shouldn't use the address operator, &, in your printf. %s expects to have a pointer passed to printf and using the name of the array as sentence is actually the same as a pointer to the start of the array, i.e sentence == &sentence[0]

Categories : C

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

How to read font size of each word in a word document using POI?
Yes, that's the correct way; the measurement is in half points. In a docx, you'd have something like: <w:rPr> <w:sz w:val="28" /> </w:rPr> ECMA 376 spec on @sz defines the unit as ST_HpsMeasure (Measurement in Half-Points) Its the same with the binary doc format, which HWPF supports. If you look at [MS-DOC], you'll see it also specifies the size of text in half-points.

Categories : Java

Data saved twice when it contains "select" word using CodeIgniter + PDO + SQL Server
This is a bug in the pdo driver... I'm going to check github to see if this has been fixed or send a pull request to fix it. This issue has been fixed. I recommend updating your codeigniter install. I cloned the codeigniter repo @ github and was not able to replicate the error. here is the bug: line 197 in pdo_driver.php if (is_numeric(stripos($sql, 'SELECT'))) { $this->affect_rows = count($result_id->fetchAll()); $result_id->execute(); } else { $this->affect_rows = $result_id->rowCount(); } here is the fix: if (is_numeric(stripos($sql, 'SELECT')) && stripos($sql, 'SELECT') == 0) { $this->affect_rows = count($result_id->fetchAll()); $result_id->ex

Categories : PHP

How to reduce the memory size of the image saved in Document Directory?
Make thumbnail of the images before you add them to the UITableView. In this way the size of the images would reduce drastically. Use the following code on the UIImages you are picking from the document directory . UIImage *originalImage = ...; CGSize destinationSize = ...; UIGraphicsBeginImageContext(destinationSize); [originalImage drawInRect:CGRectMake(0,0,destinationSize.width,destinationSize.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Also have a look at the following links :- Thumbnail view of images http://www.icab.de/blog/2010/10/01/scaling-images-and-creating-thumbnails-from-uiviews/ https://gist.github.com/djbriane/160791

Categories : IOS

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

Returning a Unicode string vs. Returning a normal string encoded as UTF-8?
UTF-8 is an encoding of the entire Unicode character set. It is backwards compatible with ASCII. For characters outside the ASCII set, multibyte encodings are used. All ASCII strings are Unicode strings. All Unicode strings are not ASCII strings.

Categories : Python

Insert each word of string into vector and calculating occurrence of each word
you are using iterator for the string, so you iterate through the characters. instead, do a split to the string and iterate the strings in the result std::string word; while( getline(writable, word, ' ') ) { ++src[word]; } for more information read here

Categories : C++

Replace A string token in Word document with a word table
Try this: protected void InsertTableAtBookMark(string[][] docEnds, string bookmarkName) { Object oBookMarkName = bookmarkName; Range wRng = WordDoc.Bookmarks.get_Item(ref oBookMarkName).Range; Table wTable = WordDoc.Tables.Add(wRng, docEnds.Length, docEnds[0].Length); wTable.set_Style("Table Grid"); for (int i = 0; i < docEnds.Length; i++) { for (int j = 0; j < docEnds[0].Length; j++) { wTable.Cell(i, j).Range.Text = docEnds[i][j]; wTable.Cell(1, 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; wTable.Cell(1, 1).VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter; } } Borders wb = wT

Categories : Dotnet

to get the sub-string which has common starting word and ending word in Excel VBA
The following code reads the string in cell A1 of Sheet1, extracts the substrings of interest, and writes them back to the worksheet in columns B, C & D. Sub ExtractFromLog() Dim str As String Dim entries() As String Dim numEntries As Long Dim i As Long Dim startPos As Long Dim endPos As Long str = Sheet1.Range("A1").Value numEntries = (Len(str) - Len(Replace(str, "fullPath", ""))) / Len("fullPath") ReDim entries(1 To numEntries) startPos = 1 For i = 1 To numEntries startPos = InStr(startPos, str, "fullPath") endPos = InStr(startPos + 1, str, "levelName") - 1 entries(i) = Mid(str, startPos, endPos - startPos + 1) startPos = endPos + 1 Next i Sheet1.Range(Cells(1, 2

Categories : Excel

Python string, find specific word, then copy the word after it
It's not the most efficient code in the world, but it is still probably better than a regex: tokens = teststring.split() numlist = [val for key, val in zip(tokens, tokens[1:]) if key == 'number:'] for your follow-up and more general queries: def find_next_tokens(teststring, test): tokens = teststring.split() return [val for key, val in zip(tokens, tokens[1:]) if test(key)] Which could be called as: find_next_tokens(teststring, lambda s: s.startswith('number') and s.endswith(':')) This will help if the keys to search for come from user input: find_next_tokens(teststring, lambda s: s in valid_keys)

Categories : Python

php: get the word coordinates (sentence num, word num) by position of character in the string
You can do something like: function positionFinder($text, $n) { $s=$text[$n]; $i=0; $sep = array(" ", ".") while (!in_array($text[$n-$i],$sep)) { $s = $text[$n+$i].$s; $i++; } $i=1 while (!in_array($text[$n+$i],$sep)) { $s .= $text[$n+$i]; $i++; } return s; } But would be faster if you create a "positionFinder" array like: function makearray($text) { $sentences = explode(". ", $text); $positionFinder = array(); $slen = 0; for ($i=0; $i<count($sentences); $i++) { $words[$i] = explode(" ", $sentences[$i]); for ($ii=0; $ii<count($words[$i]); $ii++) { $positionFinder[$slen] = $words[$i][$ii]; $slen += strlen($words[$i])+1; //+1 because of " " } $slen

Categories : PHP

Find a word in a string that starts with "PID" and return the word (in R)
str <- c("PID442 WALKS TO TOWN", "I AM PID1") gsub(".*\b(PID\d+)\b.*", "\1", str) #[1] "PID442" "PID1" \b is a word boundary which matches at the start or the end of a word \d+ corresponds to a positive amount of digits .* is a nonnegative amount of anything \1 replaces every element of str with the PID\d+, i.e. the part of regular expression that is inside the first parentheses

Categories : Regex

search a string for a word and replace that word with different links php
Like in this topic you can do something like that (with preg_replace) : $str = 'abc and abc'; $str = preg_replace('/abc/', 'google', $str, 1); $str = preg_replace('/abc/', 'yahoo', $str, 1); echo $str; It will display : "google and yahoo" (I hope I understood your need)

Categories : PHP

taking input of a string word by word
Put the line in a stringstream and extract word by word back: #include <iostream> #include <sstream> using namespace std; int main() { string t; getline(cin,t); istringstream iss(t); string word; while(iss >> word) { /* do stuff with word */ } } Of course, you can just skip the getline part and read word by word from cin directly. And here you can read why is using namespace std considered bad practice.

Categories : C++

String, word to word translation
Here is something that might work... Dictionary<string, string> EnglishHindiTranslations = null; public void Populate() { EnglishHindiTranslations = new Dictionary<string, string>(); EnglishHindiTranslations.Add("my","mera"); EnglishHindiTranslations.Add("is","hai"); EnglishHindiTranslations.Add("Name","naam"); } public string TranslateHindiToEnglish(string hindiWord) { string value = EnglishHindiTranslations.FirstOrDefault(x => x.Value == hindiWord).Key; if(string.IsNullOrEmpty(value)) { return hindiWord; } return value; } public string TranslateEnglishToHindi(string englishWord) { string value = EnglishHindiTranslations.FirstOrDefault(x => x.Key == englishWord).Value; if(string.IsNullOrEmpty(value)) {

Categories : C#

Word size mul in Assembly
If cmp word[ebp+4], 1 isn't working, that indicates that what's at word[ebp+4] may not be what you expect or what it should be. The upper byte of the word is evidently not 0. Using the byte compare instead is covering up an issue somewhere. So you'll need to examine what's happening with the word at that location.

Categories : Assembly

Is it better to make a method for returning a string from an Enum? or to have an extra string variable to hold the string value?
Your getSize() method can be reduced to: public string getSize() { return pSize.ToString(); } Given that the method is really this simple, it seems rather pointless to provide this as a separate method. If you simply expose pSize as a property (or read-only property) the user can simply call ToString() on that property: public EnumSize Size { get { return this.pSize; } }

Categories : C#

Count XML Elements, which are saved as a String
I guess you'd like to parse your string as XML ? Explained here: In Java, how do I parse XML as a String instead of a file? Another solution but really ugly: if you are 100% sure of your XML structure (and sure that it won't change), you may as well count there number of "<PolylinePoint"

Categories : Java

Get string from NSArray, saved using NSUserDefaults
Instead of adding the @"%@" strings twice at the beginning of the array with: NSArray *saveStrings = [[NSArray alloc] initWithObjects:@"%@", @"%@", yourNameTextField.text, customPhraseTextField.text, nil]; Insert just the variables with: NSArray *saveStrings = [[NSArray alloc] initWithObjects:yourNameTextField.text, customPhraseTextField.text, nil]; With the code you have, the array has 4 objects, the first and second of which are the strings @"%@" and @"%@" again. Thus, when you call [loadStrings objectAtIndex:0] and [loadStrings objectAtIndex:1], the output is those first two strings, @"%@" and @"%@". In other words, you're not first defining the formats of the objects and then passing the variables containing the strings with initWithObjects: but rather just the objects themselve

Categories : Objective C

string getting truncated when saved into database
As I mentioned in my comment, do not use TEXT as it is deprecated. Use VARCHAR or NVARCHAR for Unicode data. This will allow you to store up to 2GB of data. http://msdn.microsoft.com/en-us/library/ms186939.aspx Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes. The ISO synonyms for nvarchar are national char varying and national character varying. 2,147,483,647 bytes is approximately 1.862GB and the maximum capacity for that column. I assume the data you're attempting to store is too large for the column, hence the data being truncated.

Categories : C#

Buffer allocation not in multiple of word size
Here's my doubt, how can the difference between buffer1 and buffer2 be 0x10, when everything is allocated in a multiple of wordsize. First, a correction: the difference between buffer1 and buffer2 is 10, not 0x10 (which is 16). Second, not everything is allocated in multiple of words. The total frame size will be divisible by at least 8 to keep stack properly aligned for doubles, but individual local variables will only be aligned by whatever their alignment requirement is (which is 1 for characters and character buffers).

Categories : C

Python: search longest palindromes within a word and palindromes within a word/string
Your solution seems a bit complicated to me. Just look at all of the possible substrings and check them individually: def palindromes(text): text = text.lower() results = [] for i in range(len(text)): for j in range(0, i): chunk = text[j:i + 1] if chunk == chunk[::-1]: results.append(chunk) return text.index(max(results, key=len)), results text.index() will only find the first occurrence of the longest palindrome, so if you want the last, replace it with text.rindex().

Categories : Python

How to increase the font size of first two letters of any word/sentence?
If you add vertical-align:top to the span, it will align the words after the span to the top of the span Fiddle Other properties include middle bottom baseline

Categories : HTML

How do I change the font and size of a hyperlink inserted into ms word with vba
You can; With wrdDoc.Hyperlinks.Add(Anchor:=wrdDoc.Bookmarks("LCEmail").Range, Address:="abc@yahoo.com") .Range.Font.Name = "Microsoft sans serif" .Range.Font.Size = 10 End With

Categories : Vba

iOS returning image with different size?
why dont you try like this? you will get size in bytes NSData *data = [[NSData alloc] initWithData:UIImageJPEGRepresentation((Your Image), 0.5)]; int imageSize = data.length; NSLog(@"size of image is: %i ", imageSize);

Categories : IOS

Form with entity field, saved in database rare string
You need to do a ManyToMany relationship between Twitterposts and Tags entity. You need to put something like this into you Twitterposts entity: /** * @ORMManyToMany(targetEntity="Tags", inversedBy="twitterposts") * @ORMJoinTable(name="twitterpost_tags", * joinColumns={@ORMJoinColumn(name="twitterpost_id", referencedColumnName="id")}, * inverseJoinColumns={@ORMJoinColumn(name="tag_id", referencedColumnName="id")} * ) */ private $tags; And get this as an ArrayCollection: public function __construct() { $this->tags = new ArrayCollection(); } Make getter and setter to this element and do the other side too in your Tags entity. Here is the Doctrine documentation: http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#many-to-many-unidirectional

Categories : Forms

Convert string saved in hex format to its previous form in python
That string appears to be using percent-encoding, which means you first have to unescape it. You could do something like import urllib s = "%D0%9D%D2%B1%D1%80%D1%81%D2%B1%D0%BB%D1%82%D0%B0%D0%BD_%D3%98%D0%B1%D1%96%D1%88%D2%B1%D0%BB%D1%8B_%D0%9D%D0%B0%D0%B7%D0%B0%D1%80%D0%B1%D0%B0%D0%B5%D0%B" print urllib.unquote(s) Which gives an output of Нұрсұлтан_Әбішұлы_Назарбаев The result of urllib.unquote will give you a unicode-escaped string. The Python 3 equivelant is, I think, urllib.parse.unquote().

Categories : Python

Determine last character in PHP string, replacing and returning the string with new characters
this is wrong if ($last_char != "." || "!" || "?") because "!" and "?" are non-zero, so though the first condition is false the next 2 conditions are always true. As a result the whole statement is true. try if ($last_char != "." && $last_char!="!" && $last_char!="?") {

Categories : PHP

Why [UIScreen mainScreen].bounds] is not returning full screen size?
You have to add the iPhone 5 Launch image (Default-568h@2x.png) to your project. The 568 point tall launch image tells iOS to launch your app in 4" mode. If you don't have this image, your app is treated as a 3.5" app. Even if it is 4" compatible.

Categories : IOS

C++ std::vector in class, function crash on returning value and size growing in foreach
From the looks of it, you are deleting something which looks like a string using delete rather than delete[]. Of course, this assumes that the string was allocated in the first place. Based on your comment you try to delete a string literal which causes undefined behavior at that point. That said, please note that you are slicing your object when you insert it into the vector and, more importantly, you don't get a deep copy of the ContentEntry members (this type is lacking a copy constructor and probably an assignment operator). Thus, after inserting the ContentEntry into your std::vector<ContentEntry> the newly allocated object is gone. Another interesting bit is that you cast your T* to a Content*. The allocate object is deleted through a pointer to Content. Thus, either the cast

Categories : C++

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#

Get the last word of a string
It depends on what you try to do (it is hard to understand from your description) but to get the last word from a string you can do: $split = explode(" ", $string); echo $split[count($split)-1]; See How to get last string in sentences using php? for more information.

Categories : PHP

Get first word of string
Split again by a whitespace: var firstWords = []; for (var i=0;i<codelines.length;i++) { var words = codelines[i].split(" "); firstWords.push(words[0]); } Or use String.prototype.substr() (probably faster): var firstWords = []; for (var i=0;i<codelines.length;i++) { var codeLine = codelines[i]; var firstWord = codeLine.substr(0, codeLine.indexOf(" "));   firstWords.push(firstWord); }

Categories : Javascript

Get word from string AS3
var fullCommand : String = "/kick Frank"; var parts : Array = command.split( " " ); var command : String = parts[ 0 ]; var target : String = parts[ 1 ]; switch( command ) { case "/kick": { trace( "I am going to kick: " + target ); break; } case "/ban": { trace( "I am going to ban the face off: " + target ); break; } default: { trace( "Undefined command." ); break; } }

Categories : Actionscript



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