Posts

javascript - Make a function in .replace() -

i have following code uses regex: var mystring = "<<cool>> <<stuff>>" var regexstring = /<<([^\:]{0,})>>/gi mystring.replace(regexstring, "$1") i able replace string based on text on capture group. like: var mystring = "<<cool>> <<stuff>>" var regexstring = /<<([^>]{1,})>>/gi mystring.replace(regexstring, function(var0) { //var0 being text capture group if(var0 == "cool") { console.log("got cool") } else { console.log("didn't cool") } }) is there someway this? yes, can use function second argument of .replace() . example: mystring.replace(regexstring, function(match, group1) { // group1 here }); reference: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/replace

sockets - C++ overload << operator for class object acting as stream -

so i've browsed bunch of other threads, none pertain questions have on exact topic. writing c++ library socket communication. have tcp socket class handles operations on tcp socket (setup, read/write, etc). want able read , write data to/from tcp socket object using << , >> operators. example, want able write, say, double socket in fashion: double x; tcpsocket *sock = new tcpsocket(); //socket setup stuff here... sock << x; at moment, have 2 templated overloaded operator functions within tcpsocket class: template<typename t> tcpsocket operator<<(tcpsocket sock, t &val) { unsigned char bytesofval[] = //parse bytes of val here... sock.write(bytesofval, sizeof(bytesofval)); } - template<typename t> tcpsocket operator>>(tcpsocket sock, t &val) { std::stringstream ss; byte buf[sizeof(val)]; sock.read(buf, sizeof(buf)); ss.str(std::string(buf)); ss >> val; } where sock.read( ) , sock...

Android task/stack: why new task created in this case? -

Image
i'm trying clear task/back stack on android @ http://developer.android.com/design/patterns/navigation.html . when reach part below have question. please take on first (or go link above read post) however, touching compose activity, user indicates desire remain within gmail. gmail's conversation list activity appears, , new task b created it. new tasks rooted home, touching conversation list returns there. task persists in background, , user may return later (for example, via recents screen). if gmail had own task running in background, replaced task b—the prior context abandoned in favor of user's new goal. now, question. why create new task b in case? (when user touching compose activity) what means "it replaced task b" could make clear, please!? check link, that's because recent task have change in lollipop

npm search is not to work.Why? -

want know npm search not going official website find package? if , why npm search query seems set in local index , results did not find.please me! the npm repo official site find node modules. if don't results want can use other alternative search sites like: http://search.node.modules.by.locoticket.com (this best far) http://nipstr.com/

vba - Copying a row in excel from one sheet to another after searching for a given value -

disclaimer... not looking code me, point me in correct direction or give me examples can work with. problem: have workbook has 2 pages. first if formatted this hostname chassis service tag asset tab location u lcldhv003-25 pe r610 1*v4yq1 1*1315 d3sf85.08 21 lcmntypxyb02 pe r610 bz00l1 19368 x3sd04.34 36 lemailmig001 pe 1950 9zvsj1 12078 x3se07.12 29 lpasscdb01-01 pe r710 3xsvh1 11415 p3sd02.22 03 i need search in in location field given value (example x3sd04) , insert row second table. need have existing data moved down page. i have seen vlookup index, match , vba options. have tried has failed. try this: sub test() dim searchstring$, cl range, n& searchstring = "x3sd04" n = sheets("sheet2").cells(rows.count, "a").end(xlup).row + 1 'get row insert copied row set cl = sheets("sheet1").cells.find(searchstring) 'fin...

elasticsearch - JsonParseException Unexpected character (':') (for unquoted name) or double-quote (for quoted) to start field name -

jsonparseexception: unexpected character (':' (code 58)): expecting either valid name character (for unquoted name) or double-quote (for quoted) start field name my mapping structure { "patientinfo": { "properties": { "address": { "type": "nested", "properties": { "patient_current_address": { "type": "string" }, "patient_old_address": { "type": "string" }, "patient_origin_address": { "type": "string" } } } } } } the code build bulk request looks this: bulkrequestbuilder bulkrequest = client.preparebulk(); xcontentbuilder xb = xcontentfactory.jsonbuilder().startobject(); xb.startobject(); xb.field("globalid","196ad302157add3ad63cd1154e968dfa...

wordpress - How to fix this invalid php code -

in error.log i'm seeing appear multiple times before suffer serious memory leaks php warning: implode() [function.implode]: invalid arguments passed in /home/daxcentr/public_html/wp-content/themes/reload/masonry-layout/fishtail/style.php on line 3 the code style.php here: <?php $mediaurl = wmlp_layout_url(__file__); // donot remove ?> <style> .wmle_container .wmle_item{box-shadow:<?php echo implode($layoutsettings['box_shadow'],' '); ?>; margin:10px;-webkit-border-radius: <?php echo implode($layoutsettings['box_border'],' '); ?>; border-radius: <?php echo implode($layoutsettings['border_radius'],' '); ?>;} .wmle_container .wmle_item .wpme_image a{ display:block; padding:10px;} .wmle_container .wmle_item .wpme_image img{box-shadow:none !important; display:block; margin:auto;-webkit-border-radius: <?php echo $layoutsettings['border_radius'][0]; ?> <?php echo $layoutset...