substring

jquery - get part of path?

ⅰ亾dé卋堺 提交于 2020-01-06 06:50:23
问题 I have a url that looks like this : http://mysite.com/1/2/Simpson and I want to create a variable that contains just Simpson... Not sure how to do it here... I have: var myvar = window.location.pathname and have tried something using substring, but can't seem to get it to work? 回答1: this may work, but you might as well use the string window.location.href, not the object window.location (which contains many different objects within it): var dirs = window.location.href.split( '/' ); however,

Extract a substring betwen the closer SPACE and a certain character

佐手、 提交于 2020-01-06 06:37:07
问题 As I have to extract the attribute 'inches' from products description, I need a function that extract substring between its closer space recurrence and ". This is for PHP editor of the WP plugin All-Import. $str = "SIM UMTS ITALIA 15.5" BLACK"; $from = " "; $to = '"'; function getStringBetween($str,$from,$to){ $sub = substr($str, strpos($str,$from)+strlen($from),strlen($str)); return substr($sub,0,strpos($sub,$to)); } I excpected: 15.5 Results: SIM UMTS ITALIA 15.5 回答1: Based on comments to

counting punctuation in a given text

谁说我不能喝 提交于 2020-01-06 05:48:08
问题 I have a text file with a huge text written in forms of paragraphs. I need to count certain pieces of punctuation: , and ; from that text without using any module, not even regex . In addition, my program also needs to count ' and - , but only under certain circumstances. Specifically, it should count ' marks, but only when they appear as apostrophes surrounded by letters, i.e. indicating a contraction such as "shouldn't" or "won't" . (Apostrophe is being included as an indication of more

Remove all lines which do not contain a period

假装没事ソ 提交于 2020-01-06 05:25:54
问题 I have a text like this in %userprofile%\i.txt : PDF wikkipedia.ord notavalidURL snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox I want to convert it to a string like this: wikkipedia.ord snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox! I want to do this using native cmd.exe syntax only (no powershell, cygwin, etc.). So I know that I can do this: @echo off setlocal EnableDelayedExpansion set row= for /f %%x in (%userprofile%\i.txt) do set "row=!row!%%x" echo %row% >

awk - remove character in regex

回眸只為那壹抹淺笑 提交于 2020-01-05 21:31:10
问题 I want to remove 1 with awk from this regex: ^1[0-9]{10}$ if said regex is found in any field. I've been trying to make it work with sub or substr for a few hours now, I am unable to find the correct logic for this. I already have the solution for sed: s/^1\([0-9]\{10\}\)$/\1/ , I need to make this work with awk . Edit for input and output example. Input: 10987654321 2310987654321 1098765432123 (awk twisted and overcomplicated syntax) Output: 0987654321 2310987654321 1098765432123 Basically

Pandas find super string in one Series from another Series

霸气de小男生 提交于 2020-01-05 08:41:54
问题 This does not need to necessarily be done in pandas but it would be nice if it could be done in pandas. Say I have a list or Series of strings: ['XXY8779','0060-19','McChicken','456728'] And I have another list or Series which contains sub-strings of the original like so: ['60-19','Chicken','8779','1124231','92871','johnson'] And this would return something like: [True, True, True, False] I'm looking for a match that is something like: ^[a-zA-Z0-9.,$;]+ < matching string in other list > So in

Objective-C: Substring and replace

二次信任 提交于 2020-01-05 08:04:39
问题 I have a NSString which is a URL. This URL need to be cut: NSString *myURL = @"http://www.test.com/folder/testfolder"; NSString *test = [myURL stringByReplacingCharactersInRange:[myURL rangeOfString:@"/" options:NSBackwardsSearch] withString:@""]; I have this URL http://www.test.com/folder/testfolder and I want that the test variable should have the value http://www.test.com/folder/ , so the testfolder should be cut. So I tried to find the NSRange testfolder to replace it with an empty string

Finding a word from a list of strings

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 07:42:10
问题 Say I have a list of strings ["rdfa", "gijn", "ipqd"] and have a variable containing the string "and", how would I be able to check if "and" is in the list? To make this more clear think of the list as a word search: rdfa gijn ipqd I see the vertical word "and", but how would I be able to check if the word "and" is in the list? Finding horizontal words was much easier, but finding a vertical word is confusing me. I was thinking possibly that I would need to find if the first letter of "and"

Finding a word from a list of strings

守給你的承諾、 提交于 2020-01-05 07:42:02
问题 Say I have a list of strings ["rdfa", "gijn", "ipqd"] and have a variable containing the string "and", how would I be able to check if "and" is in the list? To make this more clear think of the list as a word search: rdfa gijn ipqd I see the vertical word "and", but how would I be able to check if the word "and" is in the list? Finding horizontal words was much easier, but finding a vertical word is confusing me. I was thinking possibly that I would need to find if the first letter of "and"

Extracting part of a string using sql

☆樱花仙子☆ 提交于 2020-01-05 04:23:46
问题 I have a string which is of the form Text I Want to Discard (TEXT I WANT) I only want the part of the string contained in brackets. How do I go about getting this substring? 回答1: How about this: select substring(col, charindex('(', col), len(col)) from yourtable; See SQL Fiddle with Demo Or check for both brackets. This gets the location of the opening bracket ( and then returns the length of the string between the opening and closing bracket: select substring(col, charindex('(', col),