w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to find multiple substrings of a string, but if multiple are not found, still return however many substrings were found
First, for sake of simplicity, consider those substring variables as an array. Now, the code may look like this, function doIt($string, $sub_strings){ foreach($sub_strings as $substr){ if(strpos($string, $substr) !== FALSE) { return $string; // at least one of the needle strings are substring of heystack, $string } } return ""; // no sub_strings is substring of $string. } and to use this function, echo doIt($string,array($str1,$str2,$str3,$str4)); Thanks to Orangepill!

Categories : PHP

Break strings into substrings based on delimiters, with empty substrings
Now that we've cleared up what the question is about, here's the issue. Your gmatch pattern will return all of the matching substrings in the given string. However, your gmatch pattern uses "+". That means "one or more", which therefore cannot match an empty string. If it encounters a ^ character, it just skips it. But, if you just tried :gmatch("[^^]*"), which allows empty matches, the problem is that it would effectively turn every ^ character into an empty match. Which is not what you want. What you want is to eat the ^ at the end of a substring. But, if you try :gmatch("([^^])^"), you'll find that it won't return the last string. That's because the last string doesn't end with ^, so it isn't a valid match. The closest you can get with gmatch is this pattern: "([^^]*)^?". This has t

Categories : Lua

Delete multiple rows by sql statement "delete from tableName" whereas TRIGGER "After Delete" had applied on that
Either set @roid=(select ReachOutID from deleted(nolock) where deleted.NotificaionType='reachoutlike') Or set CACHE_Reachout.LIKEcount= (select [dbo].[getReachout_Notification_Count](@roid,'like') ) where CACHE_Reachout.ReachOutID=@roid is returning more than 1 row of data. Raj

Categories : Sql Server

Search for multiple RegEx substrings
Don't search for the pound sign. Search for the numbers, then manually add the pound sign yourself. import re strings = [ "5.20", "$5.20", "$.50", "$5", "Shipping is free", "Shipping: not specified", "free", "not specified", ] pattern = r""" d* #A digit 0 or more times [.]? #A dot, optional d+ #A digit, one or more times | free #Or the word free | not s+ specified #Or the phrase "not specified" """ regex = re.compile(pattern, flags=re.X) results = [] for string in strings: md = re.search(regex, string) if md: match = md.group() if re.search(r"d", match): match = "$" + match results.append(match) else:

Categories : Python

extracting multiple substrings from string using sed
What I would do is to use sed 's/regex to match the old string/new string/' and then write it to a file. so it would be something like this: sed 's/regex to match the old string/new string/' > file and ofcourse to provide sed with input just redirect the standard output of cat: cat thefile.txt | sed ...

Categories : Regex

Multiple substrings with table and column aliases
select PageRequested, count(PageRequested) as Hits from ( select substring_index(substring_index(origcmd, '.', -2), ' ', 1) as PageRequested from weblog) temp group by PageRequested order by Hits desc Working SQLFiddle : http://sqlfiddle.com/#!2/94d04/3

Categories : Mysql

Regex for identifying and seperate multiple substrings from a single string
You would need to do this with two seperate passes. Each pass would look for the values you're interested in Pass 1: (?<=s|^)(alan)(_)(d+) Pass 2: (?<=s|^)(roma)(_)(d+) However you wanted to know how to do this without the two pass solution. The best you could use an expression which places each match into a separate capture group, but I think this would be more cumbersome: (?<=s|^)(?=alan|roma)(alan)?(roma)?(_)(d+) Live Demo Sample Text How alan_613 are you roma_222 all doing alan_611 Matches In this example note how capture group 1 gets alan, or capture group 2 gets roma [0][0] = alan_613 [0][1] = alan [0][2] = [0][3] = _ [0][4] = 613 [1][0] = roma_222 [1][1] = [1][2] = roma [1][3] = _ [1][4] = 222 [2][0] = alan_611 [2][1] = alan [2][2] = [2][3] = _ [2][4]

Categories : Java

KnockoutJS: Delete multiple items using checkbox and one delete button
You can achieve this by adding new array to your vm for storing selected rows. Bind it to checkboxes using checked binding: function ViewModel() { var self = this; self.items = ko.observableArray(["One", "Two", "Three"]); self.selectedItems = ko.observableArray(); self.deleteSelected = function () { self.items.removeAll(self.selectedItems()); self.selectedItems.removeAll(); } } ko.applyBindings(new ViewModel()); <div data-bind="foreach: items"> <input type="checkbox" data-bind="value: $data, checked: $parent.selectedItems" /> <span data-bind="text: $data"></span> <br/> </div> <input type="button" value="Remove Selected" data-bind="click: deleteSelected" /> Here is an example: http://jsfiddle.ne

Categories : Javascript

Re-assigning multiple IDs upon delete
You could try creating a custom filter jquery. By the way .live() is deprecated since 1.7 Fiddle Try $(".remove").click(function() { $(this).parent().remove(); refreshIndex(); }); function refreshIndex() { $('ul li').filter(hasIdWithIndex).each(updateIdWithIndex); $('ul li input').filter(hasIdWithIndex).each(updateIdWithIndex); function hasIdWithIndex() { return this.id.search(/d$/) != -1; } function updateIdWithIndex() { var $this = $(this); var id = this.id; var index = $this.closest('li').index(); id = this.id.substring(0, id.length -1); this.id = id + index; } }

Categories : Jquery

How to delete multiple ids in mongodb?
By running remove once for each ID, or perhaps using in: db.collection.remove( { _id : { $in: [ ObjectId("51ee3966e4b056fe8f074f48"), ObjectId("51ee3966e4b056fe8f074f4a"), ObjectId("51ee3966e4b056fe8f074f4b") ] } } );

Categories : Mongodb

Is it possible to delete from multiple tables in the same SQL statement?
Nope, you'd need to run multiple statements. Because you need to delete from two tables, consider creating a temp table of the matching ids: SELECT U.Id INTO #RecordsToDelete FROM Users U JOIN LinkingTable J ON U.Id = J.U_Id ... And then delete from each of the tables: DELETE FROM Users WHERE Id IN (SELECT Id FROM #RecordsToDelete) DELETE FROM LinkingTable WHERE Id IN (SELECT Id FROM #RecordsToDelete)

Categories : SQL

How to add and delete multiple UILabel in TextField
The term you're looking for is 'token'. Try using a 3rd party solution like jstokenfield (just an example one, there are others on cocoacontrols / github).

Categories : Iphone

Vim NERDTree: How to delete multiple files at once?
As far as I know, NERDTree doesn't let you select multiple nodes so I believe you can't do what you want with that plugin. However, vim comes by default with another plugin which does a lot more than NERDTree called netrw: :help netrw. With netrw, deleting multiple files is done like that: mf (navigation) mf ... D

Categories : Vim

Multiple delete when given an array of ids using sequelize.js
If possible,avoid id with numerical value.Check this myArray=[]; or myarray.length=0 //this will refresh your array!! Assign your array with any one of the bove suggestion and your array with content will loose all its content.

Categories : Javascript

delete multiple columns by name in excel using vb.net
I was able to figure out how to do this: Dim xlWB As Excel.Workbook = CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook) Dim xlWSPosition As Excel.Worksheet = CType(CType(xlWB.Sheets("byPosition"), Excel.Worksheet), Excel.Worksheet) Dim xlWSEmployee As Excel.Worksheet = CType(CType(xlWB.Sheets("byEmployee"), Excel.Worksheet), Excel.Worksheet) Dim xlSheets As Object Dim xlSheetsArray(0 To 1) As Excel.Worksheet Dim k As Long Dim i As Long xlSheetsArray(0) = xlWSPosition xlSheetsArray(1) = xlWSEmployee For Each xlSheets In xlSheetsArray With xlSheets 'With the above sheets, replace the first 7 rows. They only contain Payscale generic information so we can get rid of it.

Categories : Vb.Net

Multiple delete with checkbox in codeigniter
Try this, $(".case").on('click',function(){ var chk=$('.case:checked').length ? true : false;// if length is > 0 then return true $('#selectall').prop('checked',chk);// if chk true then check the selectAll checkbox }); Take a look on fiddle You need to create a form submit and call the function of controller on form submit # Your Controller Function function del($reg_id) //delete content { $this->load->helper(array('form','url')); $this->load->model('registration'); $checkbox=$this->input->post('checkbox');# Using Form POST method you can use whatever you want like GET $reg_id=$this->input->post('reg_id');# Using Form POST method $regId_array=array(); foreach($checkbox as $key=>$checked) { if($checked!=

Categories : PHP

Handsontable delete multiple rows
your "selection" variable is not visible within the scope of the onClick handler. Try moving "var selection = ..." into the handler function. Something like... $('.deletebutton').on('click', function () { var selection = $edit.handsontable('getSelected'); $edit.handsontable('alter', 'remove_row', selection[0], selection[2]); });

Categories : Jquery

Delete row if multiple columns empty
Try this: Sub DeleteRows() For i = 3 to 5 Columns(i).SpecialCells(xlCellTypeBlanks).EntireRow.Delete Next The only problem with this is that if there is no blank cells it will return you with an Error. The alternative to this is to check if you have blank cells before the EntireRow.Delete. Here's how you can do it: Sub DeleteRows() Dim rngBlanks as Range Dim i as Integer For i = 3 to 5 On Error Resume Next Set rngBlanks = Columns(i).SpecialCells(xlCellTypeBlanks) On Error GoTo 0 If Not rngBlanks is nothing then rngBlanks.EntireRow.Delete End if Next let me know if this works and if you need more explanation!

Categories : Excel

Getting substrings from
You can use the String.Split method, to get array of IDs from your string Here is the documentation: http://msdn.microsoft.com/en-us/library/tabh47cf.aspx var ids = custCodes.Split("<br />"); foreach(var item in ids) { //Check the current id }

Categories : C#

MS Access : How do delete one record with multiple criteria?
Change this: CurrentDb.Execute "DELETE FROM CrewTable WHERE KitNumber = " & Me.txtClearKitEntry And ActionDate = " & Me.txtClearDateEntry" To this CurrentDb.Execute "DELETE FROM CrewTable WHERE KitNumber = " & Me.txtClearKitEntry & " And ActionDate = #" & Me.txtClearDateEntry & "#;" part of you string was not in quotes and also when using dates in sql queries in Access they have to be wrapped in #

Categories : SQL

Trying to delete each option in Multiple Choice by clicking X next to it
you could do this with something like this: <ul> <li><div class="remove">x</div>A.<input type="radio" id="q2a1" name="question" /> Red</li> <li><div class="remove">x</div>B.<input type="radio" id="q2a2" name="question" /> Green</li> <li><div class="remove">x</div>C.<input type="radio" id="q2a3" name="question" /> Blue</li> <li><div class="remove">x</div>D.<input type="radio" id="q2a4" name="question" /> Brown</li> </ul> then use javascript var divs = document.getElementsByClassName('remove'); for(var i=0; i<divs.length; i++) { divs[i].addEventListener('click', function() { var li = this.parentNode;

Categories : Javascript

Delete only one item from array having same multiple values
try like this, NSArray *array = [NSArray arrayWithObjects:@"Level1 Business", @"Level2 Economy", @"Level2 Economy", @"Level1 Business", nil]; NSMutableArray *mainarray=[[NSMutableArray alloc]initWithArray:array]; int n=[mainarray indexOfObject:@"Level2 Economy"];//it gives first occurence of the object in that array if(n<[mainarray count]) // if the object not exist then it gives garbage value that's why here we have to take some condition [mainarray removeObjectAtIndex:n]; NSLog(@"%@",mainarray); O/P:- ( "Level1 Business", "Level2 Economy", "Level1 Business" )

Categories : Iphone

How to delete rows from a table with multiple select in DB2
You could use DELETE FROM core.appuser WHERE usersnum IN ( select usersernum from core.appuser where usersernum in ( select ch.usersernum from core.appusersession ch where ch.usersernum not in ( select usersernum from ( select max(starttime) as maxstarttime, usersernum from core.appusersession vip where vip.starttime>='2011-01-01 00:00:00' group by usersernum)) group by usersernum) order by useremail);

Categories : SQL

Delete multiple Rows containing a specific String
Why do you have a problem with deleting them one at a time? It doesn't seem too inefficient... Anyway, I'm pretty sure you still have to loop over every cell to see if it contains "POST". If you have a problem specifically with deleting one row at a time, you could save the indices of the rows you want to delete in an array; then use the array to delete the saved rows.

Categories : Java

Want to delete multiple tags with same tag name in XML using python elementtree?
remove takes an element as parameter, not a xpath. Instead of: root.remove(tag_name) you should have: elements = root.findall(tag_name) for element in elements: root.remove(element)

Categories : Python

Delete from multiple tables using order by and limit
Doing it using a JOIN against a subselect to get the highest id from the my_rel_table DELETE my_rel_table, my_photo_table FROM my_rel_table INNER JOIN ( SELECT MAX(id) AS MaxId FROM my_rel_table WHERE relid = 1 AND type = 1 ) Sub1 ON my_rel_table.id = Sub1.MaxId LEFT OUTER JOIN my_photo_table ON my_photo_table.typeid = my_rel_table.typeid WHERE my_rel_table.relid = 1 AND my_rel_table.type = 1 Not directly tested as I have no test data! EDIT - Couple of attempts to do the top 5, but again not tested DELETE my_rel_table, my_photo_table FROM my_rel_table INNER JOIN ( SELECT id FROM my_rel_table WHERE relid = 1 AND type = 1 ORDER BY id DESC LIMIT 5 ) Sub1 ON my_rel_table.id = Sub1.id LEFT OUTER JOIN my_photo_table ON my_photo_table.typeid =

Categories : Mysql

MySQL Delete rows from multiple tables
since you are deleting rows from multiple table, the only missing is to specify on what tables the row will be deleted, DELETE `users`,`pd` FROM `users`, `pd` WHERE `users`.`i_uid`=`pd`.`i_uid` AND `users`.`i_uid` = 1010; in the query above, it will delete rows from both tables. I suggest to change statement using ANSI join like below, DELETE a, b FROM users a INNER JOIN pd b ON a.i_uid = b.i_uid WHERE a.i_uid = 1010 if you want to delete from users table, DELETE a FROM users a INNER JOIN pd b ON a.i_uid = b.i_uid WHERE a.i_uid = 1010

Categories : PHP

Are multiple-table DELETE statements bad practice? Why?
One possible problem that I could see is that if it there is a glitch (like a server breakdown, power outage etc) and you already deleted the parent records (from the parent table) before the related child record(s) then you have what is known as orphan record(s) meaning the related child record/table could no longer be related to a mother record/table. Although this could overcome if you delete first the child table/record before the parent table/record. Another one is performance issue since MyISAM uses table-level locking so deleting multiple records (from multiple tables) has bigger chance of degrading the access time performance than say deleting from few sources.

Categories : Mysql

C Substrings Methods
Use something like this: const char* posAtSign = strchr(searchString,'@'); if (posAtSign != NULL) { const char* posPoundSign = strchr(posAtSign+1,'#'); if (posPoundSign != NULL) { const int numChars = posPoundSign - posAtSign - 1; strncpy(substringBuffer,posAtSign+1,numChars); } } Tested code: char searchString[] = "@the president#"; char substringBuffer[128]; const char* posAtSign = strchr(searchString,'@'); if (posAtSign != NULL) { const char* posPoundSign = strchr(posAtSign+1,'#'); if (posPoundSign != NULL) { const int numChars = posPoundSign - posAtSign - 1; strncpy(substringBuffer,posAtSign+1,numChars); substringBuffer[numChars] = ''; printf("substring: '%s'", substringBuffer); } }

Categories : C

Can I delete multiple file extensions at same time in python
It seems like you just want a basic string operation, no? if filename.endswith(('.txt','.doc')): os.remove(filename) Or, negating it, if not filename.endswith('.html'): os.remove(filename) .endswith accepts a tuple of things you want to match against, returning True if any match, so if you wanted to keep .html and .txt extensions: if not filename.endswith(('.html','.txt')): os.remove(filename)

Categories : Python

Delete similarly named files in multiple directories
Use del from the command line: del /s .xconfig The /s switch instructs del to recurse into all subdirectories. Execute the command with the working directory set to the top level directory which contains these files. You are having no luck from the Explorer shell because it does not regard such a file (no name, only an extension) as being valid. But del is quite happy to delete such files.

Categories : Windows

How to delete multiple images in GridView using a button in Android?
You can refer to this example Images with checkbox and on click of delete button get the image name and perform delete operation like this: File file= new File(Environment.getExternalStorageDirectory()+ "imageName"); if(file.exists()) { file.delete(); }

Categories : Android

Delete ALL duplicate rows based on multiple columns
This problem seems to require a custom algorithm. Not sure if the aforementioned RemoveDuplicates can deliver a reliable answer for a not-so-simple case, but in this kind of situations I prefer to create something from scratch. As far as your code is not too flexible, I couldn't find the way to propose my correction and thus I have created the whole loop (what I shouldn't do). Note that this code can be adapted to any number of analysed columns/rows. Also bear in mind that it relies on an on-time deletion of the target cells (instead removing the whole row, what can only be done outside the loop); this is just to show you another alternative solution; you can change this code as much as you wish. Dim maxRow As Long Dim curStep, startColumn, endColumn As Integer Dim areDuplicated As Boolea

Categories : Arrays

UITableView and swipe to delete allows multiple rows to be highlighted
OK a quick read through of all the documentation has led me to the answer. Although swipe to delete isn't unselecting my rows visibly (due to code in tableView:didSelectRowAtIndexPath: applying the highlight I want and code in tableView:didDeselectRowAtIndexPath: removing it) it is removing it from being the selected row by assigning nil to indexPathForSelectedRow. This is because, as noted in the docs, these calls are not sent when the table is in edit mode which I can only assume the whole table is during swipe to delete. Seeing as the row is actually deselected all I need to do is remove my custom highlight so I did this: - (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *selectedIndex = self.cardsTable.indexP

Categories : IOS

Entity Framework Cascade Delete with Multiple Column Key
You appear to be trying to model a many-to-many relationship between Students and Advisors. This would be the way you'd normally do that: public class Advisor { //Key fields don't need to be marked virtual public int AdvisorId { get; set; } //If you want the property to lazy load then you should mark it virtual public virtual ICollection<Student> Students{ get; set; } //Advisors have a UserProfile public int UserProfileId{get;set;} public virtual UserProfile UserProfile {get; set;} } public class Student { public int StudentId { get; set; } public virtual ICollection<Advisor> Advisors { get; set; } //Students also have a UserProfile public int UserProfileId{get;set;} public virtual UserProfile UserProfile {get; set;} }

Categories : C#

php mysql code to delete data from multiple table having same id
You can do multiple table deletes:- http://dev.mysql.com/doc/refman/5.0/en/delete.html For example say you had 4 tables and want to delete all the records in 3 of them that relate to the 1st table:- DELETE Table1, Table2, Table3 FROM Table0 INNER JOIN Table1 ON Table0.Id = Table1.ParentId INNER JOIN Table2 ON Table0.Id = Table2.ParentId INNER JOIN Table3 ON Table0.Id = Table3.ParentId WHERE Table0.Id = 1 Of course you could also delete from the first table (Table0) as well.

Categories : PHP

How to add multiple Get Post and Delete methods in RESTful Service
Most of the information you require can be found here: http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection You can specify the HTTP method with an attribute: AcceptVerbs, HttpDelete, HttpGet, HttpHead, HttpOptions, HttpPatch, HttpPost, HttpPut. Otherwise, if the name of the controller method starts with "Get", "Post", "Put", "Delete", "Head", "Options", or "Patch", then by convention the action supports that HTTP method. If none of the above, the method supports POST. The Uri will depend on the name of the controller: /api/controller-name/GetAllUsers

Categories : Rest

To delete Multiple block of data from a file in perl?
Using XML::XSH2, a wrapper around XML::LibXML: open /tmp/uday/testng-results.xml ; remove //test[@name=""][class[@name="48."]] ; save :b ;

Categories : Regex

WordPress delete_user hook when delete multiple users
The wordrpess shows correct error message. Instead of using include('sso_functions.php'); line try using it if(!function_exists('login')){ include('sso_functions.php'); }

Categories : PHP

Finding repetitive substrings
To find two or more characters that repeat two or more times, each delimited by spaces, use: (.{2,}?)(?:s+1)+ Here's a working example with your test string: http://bit.ly/17cKX62 EDIT: made quantifier in capture group reluctant by adding ? to match shortest possible match (i.e. now matches "string" and not "string string") EDIT 2: added a required space delimiter for cleaner results

Categories : Python



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