w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to find the the word position (not character position) in a string
One solution (there probably is a more efficient way) would be to split the string and iterate over the returned array: Function wordPosition(sentence As String, searchWord As String) As Long Dim words As Variant Dim i As Long words = Split(sentence, " ") For i = LBound(words, 1) To UBound(words, 1) If words(i) = searchWord Then Exit For Next i 'return -1 if not found wordPosition = IIf(i > UBound(words, 1), -1, i + 1) End Function You can call it ilke this: Sub AnExample() Dim s As String Dim sought As String s = "Take these broken wings and learn to fly" sought = "broken" MsgBox sought & " is in position " & wordPosition(s, sought) End Sub

Categories : String

Search an NSMutableArray with strings if string is equal to other string NLog position of item
Try using NSRange If you want to search for a substring NSString *homebrew = @"Rajneesh071"; NSRange range = [homebrew rangeOfString:@"Raj"]; // Did we find the string "Raj" ? if (range.length > 0) NSLog(@"Range is: %@", NSStringFromRange(range)); In your code you can do it like. for(int i=0;i<[lines count]; i++) { NSRange stringRange = [[lines objectAtIndex:i] rangeOfString:@"Period:" options:NSCaseInsensitiveSearch]; if(stringRange.location != NSNotFound) { [Eventarray addObject:Periode]; } }

Categories : Objective C

Compare string array with a single string entered by user , it also tell that it is found 2times &at that position
You have to use std::strcmp from cstring: Full code: #include<iostream> #include<cstring> using std::cout; using std::endl; using std::cin; using std::strcmp; int main() { char str[3][10], search[10]; int i, t = 0, k; cout<<"Enter 3 Names Of Fruit"<<endl; for( i = 0; i < 3; i++ ) cin>>str[i]; cout<<"Enter Fruit Name To Search"<<endl; cin>>search; for( i = 0; i < 3; i++ ) { if( strcmp(search, str[i]) == 0) { t++; k=i; } } cout << "The " << search << " is found " << t << " times and is at position " << k + 1 << endl; cin.get(); return 0; } Sample run: Enter 3 Names Of Fruit b

Categories : C++

Get int position from string PHP
You could use preg_match() to catch the integer at the start of the string. http://php.net/manual/en/function.preg-match.php

Categories : PHP

Position of character in a string
As simple as str.indexOf('a') + 1 for an arbitrary non-digit character it could be str.match(/D/).index + 1 for the last non-digit character followed by 0..inf digit characters: str.match(/Dd*$/).index + 1

Categories : Javascript

Split String With Position ID
Please try this CREATE function [dbo].[listtorow2](@l varchar(200),@id int) returns @csv table(strdata varchar(20),id INT,Position_ID int) as begin declare @xml xml set @xml = '<root><record>' + replace(@l,',','</record><record>') + '</record></root>' insert into @csv(strdata,id,Position_ID) select *,@id,ROW_NUMBER()OVER(ORDER BY (SELECT 1)) from( select t.value('.','varchar(150)') as [items] from @xml.nodes('//root/record') as a(t)) data return end go DECLARE @t TABLE(id INT,autor VARCHAR(50)) INSERT INTO @t(id,autor)values (1,'Ali,Ahmad,David,Kumar'),(2,'Aslam,Abid,John') SELECT t.id,strdata,Position_ID FROM @t t CROSS APPLY[dbo].[listtorow2](t.autor,id) t1

Categories : String

Search for an position of a string
You could try one of the overloads of String.IndexOf, which allows you to specify a starting position for the search: Dim lastFindIndex As Integer = 0 Dim stringToFind As String = "Find me!" Dim currentNumberOfMatches = 0 Dim matchToStopAt As Integer = 4 While lastFindIndex > -1 currentNumberOfMatches += 1 If matchToStopAt = currentNumberOfMatches Then Exit While End If lastFindIndex = MyTextBox.Text.IndexOf(stringToFind, lastFindIndex) End While When the loop exits, you know where the string was found (lastFindIndex) which you can then feed into your other logic.

Categories : Vb.Net

Finding string position with for loop
If you are using strpos(), you dont required to use for loop. you can get the results without that. <?php $string1 = "TATAGTTTCCTCTCTATAT"; $string_to_find=""; $string2 = str_repeat("AAAGCCTCAAATCTCTCTAGTAAAAAAGCCTCAAATCTCTCTAGTAAA", 6); $count = strlen($string1.=$string2); for($i = 0; $i < $count; $i++){ $string_to_find.=$string1{$i}; print(strpos($string_to_find, 'AAAAAA')); } ?> here is the code you can try.

Categories : PHP

Fix the position of image in an HTML string
if possible try to avoid uiwebview in your native application. ( however there are certain scenarios where it's recommended ). You should fetch only data from server and display as your Application UI design. If possible try to get the url of image in the RSS feed and fetch it using native API's for displaying in your view. This way you will have more control over your application. -- Vishal

Categories : HTML

Manually finding a position in a string
To get the index of a NSString, use this: NSRange range = [string rangeOfString:@"MyString"]; If there are several occurrences, you can loop trough them with this: NSUInteger count = 0, length = [str length]; NSRange range = NSMakeRange(0, length); while(range.location != NSNotFound) { range = [str rangeOfString: @"cake" options:0 range:range]; if(range.location != NSNotFound) { range = NSMakeRange(range.location + range.length, length - (range.location + range.length)); count++; } }

Categories : IOS

remove words from string by position php
This is untested but i think this is what you are looking for. This will remove every 2nd word after a deletion or when starting to count the words. $deletePos = 2; $words = explode(" ", $string); $i = 1; foreach($words as $key => $word) { if ($i == $deletePos) { unset($words[$key]); $i = 1; continue; } $i++; }

Categories : PHP

Bash: Find position of character in a string under OS X
This is a horrible hack, and may not work for all cases. tmp=${stringZ%%C12*} # Remove the search string and everything after it echo $(( ${#tmp} + 1 )) # Add one to the length of the remaining prefix

Categories : Osx

Binary String Regex Control Position
You should remove that quantifier from inside. Also, since you want to match 0 length string, you need to use * quantifier on complete regex, instead of +. Try using the following regex: (1[01]?)* This will match: 1 at first place Then 0 or 1 in the 2nd place. 0 or more repetition, will make every odd position filled with 1, and even position can contain 0 or 1. [01] is optional to match odd length string.

Categories : Java

How to dynamically find the position of string in sql server?
To find a position of a substring in a string you can use CHARINDEX() If you want to extract the number from your string you can do SELECT SUBSTRING(s, CHARINDEX('<#', s) + 2, CHARINDEX('#/>', s) - CHARINDEX('<#', s) - 2) number FROM ( SELECT 'What is <#1#/>' s ) q Here is SQLFiddle demo

Categories : SQL

finding dates and their position within a string using stanford nlp
Each CoreMap returned in the list from annotation.get(TimeAnnotations.TimexAnnotations.class) is an Annotation and you can get other attributes of it, such as the list of tokens, each of which stores character offset information. So you can finish off your example like this: List<CoreMap> timexAnnsAll = annotation.get(TimeAnnotations.TimexAnnotations.class); for (CoreMap cm : timexAnnsAll) { List<CoreLabel> tokens = cm.get(CoreAnnotations.TokensAnnotation.class); System.out.println(cm + " [from char offset " + tokens.get(0).get(CoreAnnotations.CharacterOffsetBeginAnnotation.class) + " to " + tokens.get(tokens.size() -1) .get(CoreAnnotations.CharacterOffsetEndAnnotation.class) + ']'); /* -- This shows printing out each token and its

Categories : Groovy

Regex to allow any occurrence of one symbol in any position of the string?
I think the pattern you're looking for is this: ^[+]?[0-9][0-9-]{2,9}$ This will match an optional plus, followed by a decimal digit, followed 2 to 9 decimal digits or hyphens. If you also want to ensure that the string doesn't end with a hyphen, simply use this: ^[+]?[0-9][0-9-]{1,8}[0-9]$ This will match an optional plus, followed by a decimal digit, followed 1 to 8 decimal digits or hyphens, followed by a decimal digit. Note you can also extend this to all Unicode digits (see this answer for more information): ^+?d[d-]{2,9}$ or ^+?d[d-]{1,8}d$

Categories : Regex

php add words without repeating random position in the string
// create an array of words from the original string $words = explode(' ', $string); // a new array to hold the string we are going to create $newString = array(); // loop all words of the original string foreach ($words as $i => $w) { // add every word to the new string $newString[] = $w; // loop all keywords foreach ($keywords as $kw => $pos) { // if the current index ($i) matches the position // add the keywords to the new string aswell // note that we add 1 to the index first, // since arrays have zero based indexes if ($i+1 == $pos) $newString[] = $kw; } } // create a string from the array of words we just composed $filled = implode(' ', $newString);

Categories : PHP

Finding a character at a specific position of a string
Try this simply: $word = "master"; $length = strlen($word); $random = rand(0,$length-1); if($word[$random] == 's'){ echo $word[$random]; } Here I used 0 because $word[0] is m so that we need to subtract one from strlen($word) for getting last character r

Categories : PHP

Format string text to a specific position
I think maybe you've got the format string right but the problem is the true type font. Not all characters are the same width. Courier new would work (all characters the same pixel width, including spaces) but that might not be what you want either. Might have to use a two column affair.. Maybe a table even? For example. I'll print 10 chars of i and then of A iiiiiiiiii AAAAAAAAAA See the difference in width? Stack overflow is using a true type font to display my post..

Categories : C#

To get the position of a letter from a (column)string in a table
How about this? SELECT position('o' IN FIRST_NAME) FROM employee WHERE FIRST_NAME = 'John'; If you want the position in the full name, you could do this: SELECT position('o' IN FIRST_NAME || ' ' || LAST NAME) FROM employee WHERE FIRST_NAME = 'John';

Categories : Postgresql

How do I read a Specific Line(string)(position) from a TextFile?
You may want to try out apache commons library: String expression = FileUtils.readLines("D:\TextFile.txt").get(3); Not very performant, but the API looks elegant.

Categories : Java

Remove numbers at specific position in String VBScript
Try Split on the |, emptying the value at the appropriate position, and then Join back together with the |. Option Explicit Dim input Dim lines, ub, i, lineParts Dim output input = "CRS|R|S||3.0|25|W||U||||0||ECN|211|MACROECONOMIC PRINCIPLES" & vbCrLf & _ "CRS|R|S||3.0|25|F||U||||0||CIS|105|SURVEY COMPUTER INFO SYSTEMS" & vbCrLf & _ "CRS|R|S||3.0|25|A||U||||12||CSR|207|AUTOMOBILE POLICY ADJUSTMENT" lines = Split(input, vbCrLf) ub = UBound(lines) For i = 0 To ub lineParts = Split(lines(i), "|") lineParts(12) = "" lines(i) = Join(lineParts, "|") Next output = Join(lines, vbCrLf)

Categories : Vbscript

Check String for Uppercase letter and find position
This will give you all the capital letters in a string: String inputString; String outputString = ""; for (int i = 0; i < inputString.length; i++) { c = inputString.charAt(i); ouptutString += Character.isUpperCase(c) ? c + " " : ""; }

Categories : Java

Algorithm for finding string permutations where each position varies
The problem can be trivially reduced to generating all binary sequences of length n. This has been previously addressed, for example in Fastest way to generate all binary strings of size n into a boolean array? and all permutations of a binary sequence x bits long.

Categories : String

How to Copy a string to another leaving a blank character in the first position?
Like this: if S[1] = Separator then begin SetLength(Str, Length(S)+2); Move(Pointer(S)^, Str[2], Length(S)*SizeOf(Char)); S[1] := ' '; // surely you mean Str[1] := ' ' end else begin SetLength(Str, Length(S)+1); Move(Pointer(S)^, Str[1], Length(S)*SizeOf(Char)); end; //Add Separator in the last position Str[Length(Str)] := Separator; It would be easy enough to re-work this to avoid the duplication. var dest: PChar; if S[1] = Separator then begin SetLength(Str, Length(S)+2); dest := @Str[2]; S[1] := ' '; // surely you mean Str[1] := ' ' end else begin SetLength(Str, Length(S)+1); dest := @Str[1]; end; Move(Pointer(S)^, dest^, Length(S)*SizeOf(Char)); //Add Separator in the last position Str[Length(Str)] := Separator; And so on. I'll leave it to you to polish i

Categories : String

Getting Index Position of ListView Clicked Item not getting String Value
Please do not use the static keyword better to send with intent like public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String KEY_TITLE= lv1.getItemAtPosition(position).toString(); Intent mViewCartIntent = new Intent(OldEventActivity.this, OldUploadActivity.class); mViewCartIntent.putExtra("KEY", KEY_TITLE) startActivity(mViewCartIntent); } and get in otheractivty' Bundle bundle=getIntent().getExtras(); String kettitle=bundle.getString("KEY")

Categories : Android

Adapter for spinner does not return correct position of the string in android
I'm not positive, so I apologize if this is wrong. Don't have source code to look at right now. but I think the getPosition() method does not perform a .equals() comparison, so you can't just pass in an equivalent string. So don't do myString = "asdf"; //myString is getting assigned a reference to a brand new string spinnerPosition = adapter.getPosition(myString); because mySpring is not pointing at the same object as the string in your array, even if myString.equals(originalString) may return true; This should work: //assign the reference to point at the exact same object that is in the ArrayList myString = originalString; spinnerPosition = adapter.getPosition(myString);

Categories : Android

Validating Format for Numbers and letters in specific position of a string
How about like this? string myString = "xy1234xy"; if(Regex.IsMatch(myString, "^[A-Za-z]{2}[0-9]{4}[A-Za-z]{2}$")) { // Do something } ^[A-Za-z]{2}[0-9]{4}[A-Za-z]{2}$ Edit live on Debuggex Here a DEMO.

Categories : C#

regular expression, report position by integer count from string
Is this what you want? If it is not, please elaborate your problem. >>> import re >>> >>> a = '1D10M1I10M1D' >>> >>> start = 10 >>> for num1, i_or_d, num2, m in re.findall('(d+)([ID])(d+)?([A-Za-z])?', a): ... print num1, i_or_d, start ... if num1: ... start += int(num1) ... if num2: ... start += int(num2) ... 1 D 10 1 I 21 1 D 32 UPDATE start = 10 for num1, i_or_d, num2, m in re.findall('(d+)([IDS])(d+)?([A-Za-z])?', a): if i_or_d not in 'ID': start += int(num1) + int(num2) continue print num1, i_or_d, start if num1: start += int(num1) if num2: start += int(num2)

Categories : Python

Why is the argument position of split and join in clojure.string mixed up?
You can use partial function to fix the separator argument for str/join. (-> string (str/split #"s") (modification-1) (modification-2) ;; (modification-n) ((partial str/join " ")))

Categories : String

Altering start position and insterting string into char array
No. Arrays don't have methods to insert things into them. STL containers have such methods. This is one of the many reasons why they are preferred to raw arrays. If you still need to work with raw array for some reason, you can write a function which does what you need, using additional variable to perform the copy in it. But the returned result will be a different array, not your original one.

Categories : C++

XmlpullparserException: Expected a quoted String(position:DOCDECL @1:62 in java.io.Inputstreamreader)
Try below code.. HttpTransportSE transporter; SoapSerializationEnvelope envelope; SoapObject mSoapObject = null; String METHOD_NAME = getString(R.string.soap_method_authentication); try { mSoapObject = new SoapObject(getString(R.string.soap_namespace),METHOD_NAME); mSoapObject.addProperty("TName", "test"); mSoapObject.addProperty("ColumnNameStr", "*"); transporter = new HttpTransportSE(getString(R.string.soap_main_url)); envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(mSoapObject); transporter.call(getString(R.string.soap_namespace) + METHOD_NAME, envelope); SoapObject response = (SoapObject) envelope.bodyIn; System.out

Categories : Android

Is there any difference between using absolute position around a relative position wrap and an absolute position around a static position wrap?
If you don't wrap an absolute positioned element around a relatively positioned object, in your viewport, top will be top, but if you zoom in or zoom out, it will be top of the viewport and independent of your layout, weather in case of relatively positioned objects, if an absolute positioned object is wrapped around a relatively postioned object, it will be on top under the bounds of the relatively positioned object(s). For Instance, Let us take three div tags as mentioned in the question with ids, box_1, box_2 and box_3 Let us assume the below CSS and HTML for the three div's The CSS: #box_1 { position: static; width: 200px; height: 100px; background: yellow; top:0px; left:0px; } #box_2 { position: relative; width: 1000px; height: 100px; background: red; } #box_3 {

Categories : CSS

Changing position of origin inside a window's Client area to get cursor position
The DPtoLP function converts device coordinates into logical coordinates. The conversion depends on the mapping mode of the device context, the settings of the origins and extents for the window and viewport, and the world transformation. http://msdn.microsoft.com/en-us/library/windows/desktop/dd162474(v=vs.85).aspx

Categories : Visual Studio 2010

How to detect change in orientation of android phone from horizontal position to vertical position?
You will need the Gravity Sensor: http://developer.android.com/guide/topics/sensors/sensors_motion.html In the absence of a Gravity Sensor you have to rely on Accelerometer and Gyroscope, I think.

Categories : Java

in R sampling a list of probabilities returns one position. How do I convert that position, to the element index?
Use which with argument arr.ind=TRUE to return the array indices. m <- array((1:27)*10, dim=c(3,3,3)) x <- sample(27, 1) x # [1] 20 which(m == m[x], arr.ind=TRUE) # dim1 dim2 dim3 # [1,] 2 1 3

Categories : R

How to take the position of images that are present in the response of ajax request and using the position draw lines
You can write drawMap() method call in success part of your Ajax response using setTimeOut. success : function(result) { closeDialog(); $("#"+divID).html(result); setTimeout(function() { drawMap(); }, 1000); },

Categories : Javascript

Position Absolute div inside position relative list item - Clipping issue - ie7
You can try to add overflow into class .listitem : overflow:visible; But, if you want your div to be exactly aligned to the item, make sure the list height and the div height are equals (including the padding). For exemple, if your item height is 40px, your div height, with a padding set to 10px, must be 20px. And remove the top:10px; .layer { position:absolute; top:-1px; right:10px; padding:5px; background:#993300; border:solid 1px #FFF; z-index:100; overflow:visible; height:20px; } In this exemple, i set the padding to 5px to keep the text center vertically. The height is set to 20px (2x padding + height = item height). And the top is set to -1px to deal with the 1px border. http://jsfiddle.net/KtMbA/ Hope it'll help !

Categories : HTML

how can check user is in stop position or in running position programmatically in iphone
Use the speed attribute of CLLocation, asumimg GPS enabled and set to best accuracy. If (loc.speed > 7/3.6) then running walking: < 6 km/h stopped is more difficult: no location update (measured with a timer) But you cannot distinguish between "stopped" and "no GPS available" (e.g in underground, or indoors). That would need the acceleration sensor, if the state needs to be in real time.

Categories : Iphone

Position panel in center of page with minimum left position using CSS/HTML
You could use a media query, f.e. @media (max-width: 800px) { /* this has to be the same width as the div */ div { margin-left:0; left:0; } } http://jsfiddle.net/y3zpm/

Categories : HTML



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