w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
find whether the string starts and ends with the same word
You can use str.startswith and str.endswith: >>> strs = "earthfooearth" >>> strs.startswith('earth') and strs.endswith("earth") True >>> strs = "earth" >>> strs.startswith('earth') and strs.endswith("earth") True Update: If the words are separated by spaces and the start and end string is not known then use str.split and str.rsplit: >>> strs = "foo bar foo" >>> strs.split(None, 1)[0] == strs.rsplit(None, 1)[-1] True # single word >>> strs = "foo" >>> strs.split(None, 1)[0] == strs.rsplit(None, 1)[-1] True >>> strs = "foo bar ffoo" >>> strs.split(None, 1)[0] == strs.rsplit(None, 1)[-1] False

Categories : Python

Find all words starts with @@ and ends with @@ in long string
You could maybe do the following Regex regex = new Regex("@@(.*)@@"); Or, if you dont want Regex use the following (easier to understand i think) var splittedString = yourString.Split(new string[] { "xx" }, StringSplitOptions.None);

Categories : C#

Regex to find a string within two strings but excluding anything that starts with http?
(?<=href=")(?!https?:)(.*?)(?=#fragment-[0-9]">) Also, don't use regex to parse HTML.

Categories : HTML

I want to replace content inside a String which starts with # if it starts with !# it must skip it
Use a negative lookbehind? String test = "Hello #Admin Welcome this is Your welcome page !#Admin This is #Admin"; String out = test.replaceAll("(?<!!)#Admin", "MyAdministrator"); System.out.println("OutPut: "+out); The lookbehind is (?<!!).

Categories : Java

How do I modify an existing button's onclick to open a new tab using Greasemonkey?
You can just do this: <button onClick="window.open('*my-url*');">Stock in Shop</button> There is no way to force a new tab -- the browser will respect the user's setting whether to create a new tab or a new window. I've created a JavaScript fiddle for you so that you can see for yourself how simple this is: http://jsfiddle.net/Fnz9R/ Good luck!

Categories : Javascript

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

How do I find out when a tab I've opened with greasemonkey is loaded?
I found a way around the problem... oddly enough, I couldn't do it when using GM_openInTab to create the window, but using mywin2=window.open("http://www.aywas.com/message/notices/9801049/", "my_win2"); allowed me to use the following code to detect the load and close the tab only after it was loaded enough for my purposes! (Although the 'window title' bit of that code above didn't seem to do anything...) mywin2.addEventListener('load', function() { mywin2.close() }, false);

Categories : Javascript

Replace specific table values using a Greasemonkey script
this javascript code let's you replace the content of a TD by it's index where 0 is the first element. var tbl=document.getElementsByTagName("table")[0]; //get the first TABLE var trs=tbl.getElementsByTagName('tr'); //get all TR's in that table var replaceTD=function(TRindex,TDindex,value){ trs[TRindex].getElementsByTagName('td')[TDindex].innerHTML=value; // replaced with innerText }; to change the second TD of the first TR that is not a title (so the third) your indexes will be TRindex=2 cause it starts from 0 ... and the TDindex=1 and the function you will call is : replaceTD(2,1,'WHATEVER');

Categories : Javascript

facebook tab iframe specific page open
You would need app_data URL parameter, and use a link such as http://www.facebook.com/[page_name]/?sk=app_[app_id]&app_data=[specific_page] Where app_data will be in the 'signed_request'. So you set app_data=page3, and check the parsed signed request value of app_data, and perform a redirect within your app.

Categories : Facebook

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

Open specific page in twitter bootstrap modal
Try this instead: Markup: Create a placeholder DIV to show the modal content within, like this: <a data-target="#myModal" class="quick-btn" data-toggle="modal" href="/SystemSettings/NewUser.aspx">Click Me</a> <div class="modal hide fade" id="myModal"> </div> JavaScript: Add the .aspx page's content to an iframe, like this: $(document).ready(function() { $('[data-toggle="modal"]').click(function(e) { e.preventDefault(); var url = $(this).attr('href'); $(".modal-body").html('<iframe width="100%" height="100%" frameborder="0" scrolling="no" allowtransparency="true" src="'+url+'"></iframe>') }); });

Categories : C#

How to open a folder containing a specific string? (Mac)
You have a couple problems with your script but in general you have the right idea. The main problem is that applescript doesn't work with slash delimited paths. Applescript paths are colon delimited. You can convert from slash to colon delimited using the "posix file" command. Give this a try. Good luck. set theString to "/path/to/folder/containing/projects/" display dialog "What is the ID?" default answer "" set theID to the text returned of result set macString to POSIX file theString tell application "Finder" activate set theResult to every folder of macString whose name contains theID open theResult end tell

Categories : Osx

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

Find page break in Word using OPEN XML
Figured out there is another way a page break gets added to the word document . That is using the sectPr tag the page size property . If the content size increases then the exceeding content is pushed to the next page .

Categories : C#

Open a specific foundation reveal modal on page load
Please refer to php in foundation modal (my earlier answer) to find out how Foundation Reveals work. Please check your code and make sure the actual reveal/modal is the element before the </body> (excluding <scripts>).

Categories : PHP

How to make grid view open a specific new page when clicked?
Do you want to change the activity or the content of the textview? A textview is a component of an layout. You have to set the content of layout using setContentView(R.layout.yourlayout) and if you want to change the content of the textView u first declare the text view TextView mytextView = (TextView) findViewById(R.id.textView1); then u use mytextView.setText("here is a string");

Categories : Java

Click many links, in one page, with a Greasemonkey script?
var all = document.getElementsByClassName("delete"); for(var i=0; i<all.length; i++) { var deleteUrl = all[i].href; var ifr = document.createElement("IFRAME"); document.body.appendChild(ifr); ifr.src = deleteUrl; } You could run a simple script like the above in the browser's JavaScript console or make it a bookmarklet.

Categories : Javascript

greasemonkey simple string manipulation
var url = "www.something.com/item/4563/"; var matches = url.match(/item/(d+)/); var itemNumber = matches && parseInt(matches[1], 10); console.log(itemNumber); // => 4563

Categories : Misc

how to find if a string contains numbers followed by a specific string
Use: if ( str.matches(".*\dst.*") ) String#matches() matches the regex pattern from beginning of the string to the end. The anchors ^ and $ are implicit. So, you should use the pattern that matches the complete string. Or, use Pattern, Matcher and Matcher#find() method, to search for a particular pattern anywhere in a string: Matcher matcher = Pattern.compile("\dst").matcher(str); if (matcher.find()) { // ok }

Categories : Java

Open search for string in page via javascript
Yes. Open a Google Drive Document for example, and hit Ctrl+F. You will see that Google captures the keystrokes and presents you with a custom Find box. Also, look at this answer.

Categories : Javascript

pagination codeigniter always starts at page 2 and active link is always at page 2
try a different way of solution, controller(index()) $this->load->library('pagination'); $config['base_url'] = site_url().'classname/index'; $config['per_page'] = $this->config->item('pagination_number'); $config['uri_segment'] = 4; $data['count']=$this->example_model->count(); $config['total_rows'] =$data['count']; $data['classname']=$this->example_model->getall($this->config->item('pagination_number'),$this->uri->segment(4)); $this->pagination->initialize($config); $data['page_link']=$this->pagination->create_links(); $this->load->view('users/classname.php',$data); model function getall($num,$offset) { $this->db->from('table_name'

Categories : Codeigniter

c# openfiledilaog, Open file when program starts
You can do this by setting the InitialDirectory to the desired path: myOpenFileDialog.InitialDirectory = variableHoldingThePathFromIni; That is, if I managed to get what you want from the question - it's a bit hard to tell.

Categories : C#

Selenium WebDriver: Firefox starts, but does not open the URL
Ok, after searching around for a while I noticed that usually the problem was a bug in Selenium (possible, but rather unlikely), or a proxy issue. Still, none of the answers suggesting how to solve the proxy issue seemed to work. Finally I got it: you need to unset all proxy settings everywhere (environment variables, and - in my case this was the issue- on Gnome). Later when you create the webdriver, you need to pass a profile which sets the browser proxy settings to what you actually use (in my case an automatic config url) 1) Unset the http_proxy environment variable (which is used by urllib) export http_proxy= 2) Cleared Gnome proxy settings: System --> Preferences --> Network Proxy --> Select "Direct Internet Connection" 3) Started webdriver.Firefox() with a profile which config

Categories : Python

How do I find a specific string in one of many text .log files using VBA?
Application.FileSearch was removed in 2007+ versions of Excel. A while back, I found this function which replicates it. I have used it on occasion, but ordinarily I think I just use FileSystemObject or Dir. Sub FileSearch() ' ' Example of FileSearchByHavrda procedure calling as replacement of missing FileSearch function in the newest MS Office VBA ' 01.06.2009, Author: P. Havrda, Czech Republic ' Dim sDir As String sDir = Range("K3").Value Dim FileNameWithPath As Variant Dim ListOfFilenamesWithParh As New Collection ' create a collection of filenames Dim rCount As Long 'row counter ' Filling a collection of filenames (search Excel files including subdirectories) Call FileSearchByHavrda(ListOfFilenamesWithParh, sDir, "*.xls", False) ' Print list to immediate debug window and as a message

Categories : String

Regex - find specific number in string
If your flavor supports lookahead and lookbehind, go with this: (?<!d)1234(?!d) Lookaround tests for occurences of characters without matching them. Negative lookaround only accepts when there is no occurence. If it supports word boundaries: 1234 Word boundaries include eg. whitespace and punctuation. Otherwise check for non-digit characters and add string start and end: (^|D)1234($|D) If your engine does not even support d and D, replace them by [0-9] respective [^0-9].

Categories : Mysql

find specific float number in string?
You can have a number surrounded by spaces (if it is what you are looking for) with: (?:^|s)Kd+(?:.d+)?(?=s|$) explanation: (?:^|s) # the begining of the string or a white character K # reset all that is matched before d+ # digit one or more times (?:.d+)? # optional dot and digits (?=s|$) # followed by a white character or the end of the string

Categories : PHP

php find and replace string after specific char
$story = preg_replace('/*.{8}/', $name_to_place, $story); should get you where you want to go. or if you want to replace the guts of the link with the 8 matching characters after the * then you can use. $story = preg_replace('/*(.{8})/', '<a href="#">$1</a>', $story);

Categories : PHP

How do I find the value of a variable in a specific string in jquery?
Since you are clicking on the dynamically added element, you can store the itemvalue as data to the element Ex jQuery(function($){ $('input[name=namea]').change(function(){ var itemvalue = this.value; var pa = $('<p />', { class: 'pa', html: 'Blah blah ' + itemvalue + 'blah blah.' }).data('itemvalue', itemvalue).data('otherdata', 'othervalue') $('#diva').prepend(pa); }); $('#diva').on('click', '.pa', function() { alert($(this).data('itemvalue')) alert($(this).data('otherdata')) }) }) It will give the values of itemvalue n time back Demo: Fiddle

Categories : Javascript

Find a specific string from Online Text File?
Does it bother you that it takes 10 minutes to crack an authentication system like this? Not only that, but all your users and passwords will be visible to the public for anyone who knows the address (which is easy to find using just a packet analyzer). If the answer is still no, take a look at how to use WebRequest and WebResponse to retrieve your text file: http://msdn.microsoft.com/en-us/library/456dfw4f.aspx. PS: stackoverflow is here to solve problems in your existing code, not to write the code for you.

Categories : Vb.Net

Find numbers at specific positions in a string with Regex
The problem is that your .* is greedy so it's gobbling up the ([1-9]?) that comes after it. If you use a non-greedy quantifier (.*?), you'll get the result you want: string str = "dddd - 2013-0Winter1 morning2"; Regex pattern = new Regex("^.* - ([0-9]{4}-).*?([1-9]?) .*?([1-9]?)$"); Match match = pattern.Match(str); for (int index = match.Groups.Count - 1; index > 0; index--) { str = str.Remove(match.Groups[index].Index, match.Groups[index].Length); } Console.WriteLine(str); // dddd - 0Winter morning Of course, this will produce the same result: string str = "dddd - 2013-0Winter1 morning2"; str = Regex.Replace(str, @"^(w*? [0-9]{4}-w*?)[1-9]? (w*?)[1-9]?$", "$1 $2"); Console.WriteLine(str); // dddd - 0Winter morning

Categories : C#

How to find specific related word from string of java
REGEX Pattern: @Month\),'(\.+?)'\) I did not test it, but it should do. This regex extracts one or more characters of "any char" between @Month),' and '). Part you are looking for will be in group 1.

Categories : Java

How can I find the width and height of a specific word within a string?
You'll have to wrap it in its own element or do something more obtuse (generate a new element with just those contents (somewhere offscreen perhaps), calculate the size of that element, and then remove it). You might be able to make a rough calculation based on element line-height and the width of characters (in em units), but without knowing which characters are in use or using a monospace font-family, I can't imagine it will be very accurate.

Categories : Javascript

Find a Specific String in Excel File using Apache POI API
There are two bugs I noticed in your code. First, you write the file every time you remove a row which is inefficient. Second, you only search the FIRST string-cell in the row, and if the first string-cell in the row isn't the correct one, you break. If your automatically generated file saves numbers or blank cells as strings (possible), then this will cause a difference between your hand generated excel file and the one you created with the script. I would suggest removing the second break statement. To clean up the code, I would rewrite the whole if block as follows: if(cell.getCellType() == Cell.CELL_TYPE_STRING && cell.getStringCellValue().equals("GET")){ sheet.removeRow(row); break; } else { System.out.print("Not Found! "); } The if statement works because of s

Categories : Java

How to find all commits with a specific string on the insertions and deletions?
Use git log -S"string" This will show you all commits where the number of occurances of "string" changed. If you want to see the patch itself add the -p flag or --patch flag. You an change the output of the log with --pretty, the author can be show using '%an' git log -S"string" -p --pretty="%an" For more options and information have a look at tho man pages. They are also available online (https://www.kernel.org/pub/software/scm/git/docs/git-log.html).

Categories : GIT

How to find all occurrences of specific string in long text
Since you can pass the start position into the IndexOf method, you can loop through the string by starting the search from where the last iteration left off. For instance: Dim getLiteratura As String = "'Author 1. Name of book 1. ISBN 978-80-251-2025-5.', 'Author 2. Name of Book 2. ISBN 80-01-01346.', 'Author 3. Name of book. ISBN 80-85849-83.'" Dim isbns As New List(Of String)() Dim position As Integer = 0 While position <> -1 position = getLiteratura.IndexOf("ISBN", position) If position <> -1 Then Dim endPosition As Integer = getLiteratura.IndexOf(".", position + 1) If endPosition <> -1 Then isbns.Add(getLiteratura.Substring(position + 5, endPosition - position - 5)) End If position = endPosition End If End Whil

Categories : Vb.Net

How to find which postgresql text fields do contain most occurances of a specific string?
Select the length of the value minus the length of the value after the searched-for string has been replaced with zero-length string, divided by the length of the searched-for string. http://www.postgresql.org/message-id/20091020172452.GA10593@tux

Categories : Postgresql

How to find integer value of specific characters in a Java string array?
str.substring(0) is just str again (read the docs). You are probably looking for a[i].substring(0, a[i].length() - 1) // cuts off last character

Categories : Java

Find a string and replace specific letters in batch file
Get yourself a copy of sed for your OS and call it from a batch file. sed -e 's/socc/INFA/g' inputFileName > outputFileName

Categories : String

Get specific lines out of HTML page and put into String
A straight regex may be a better idea. Try this for starters: Pattern pat=Pattern.compile("^<span style="color:blue;">&lt;p&gt;</span>.+&"); Here, ^ starts the line, the <span style="color:blue;">&lt;p&gt;</span> is matched literally, we then have one or more non-line-terminator characters: The regular expression . matches any character except a line terminator unless the DOTALL flag is specified. and the $ specifies end-of-line.

Categories : Java

Bash: loop through file line by line, find specific string and append to each subsequent line until same string is found
If I have your requirements right, this little awk program will work: awk '/^AB1/{ab1=$0;next}/^AB2/{print $0, ab1}' That will do nothing with any line which doesn't start with AB1 or AB2 and it fails to check for equality of the 12-character string following the AB1/AB2. I couldn't tell if you require that check.

Categories : Regex



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