[Solved] Python re: how to lowercase some words [closed]

Wanted solution using regex, here you are: >>> import re >>> s = “StringText someText Wwwwww SomeOtherText OtherText SOMETextMore etc etc etc” >>> def replacement(match): … return match.group(1).lower() >>> re.sub(r'([sS]\w+)’, replacement, s) ‘stringtext sometext Wwwwww someothertext OtherText sometextmore etc etc etc’ 10 solved Python re: how to lowercase some words [closed]

[Solved] How to send current URL in JavaScript?

You don’t need to send it, if you’re looking to have access to the name of the file the AJAX call was sent from in the php file that receives the request, you can use $_SERVER[‘HTTP_REFERER’]; Which is useful if you’re going to be receiving requests to that file from multiple locations. 0 solved How … Read more

[Solved] OOP login page error [closed]

This is because function is outside the class. Should be <?php include(“config.php”); class User { //Db Connect public function __construct() { $db=new db_class(); } // Registration Process public function register_user($name,$username,$password,$email) { $password=md5($password); $sql=mysql_query(“select * from login where username=”$username” or emailid=’$email'”); if(mysql_num_rows($sql)==0) { $result=mysql_query(“insert into login(username,password,name,emailid) values(‘$username’,’$password’,’$name’,’$email’)”); return result; } else { return false; } } … Read more

[Solved] How to Use the OR operator

Don’t compare int values with =, the assignment operator. Use == to compare, which results in the needed boolean. Change if((counter = 0) || to if((counter == 0) || // And the others after it also. solved How to Use the OR operator

[Solved] C error: Exited with non-zero status

gets returns char*. In this context – It is wrong to write char *[] in the function definition where you are supposedly passing a char array where input characters are being stored using gets. Also char *gets(char *str) – you need to pass a buffer to the gets where the inputted letters will be stored. … Read more

[Solved] Python script to ping linux server

You can use urllib2 and socket module for the task. import socket from urllib2 import urlopen, URLError, HTTPError socket.setdefaulttimeout( 23 ) # timeout in seconds url=”http://google.com/” try : response = urlopen( url ) except HTTPError, e: print ‘The server couldn\’t fulfill the request. Reason:’, str(e.code) except URLError, e: print ‘We failed to reach a server. … Read more

[Solved] How to create a loop that will make regression models in R? [closed]

Here’s a solution without loops. # some artificial data set.seed(1) daf <- data.frame(species = factor(paste0(“species”, c(rep(1:3, 10)))), year = rep(2000:2009, 3), x = sample(1:100, 30)) library(dplyr) library(broom) lm_fit <- daf %>% group_by(species) %>% do(fit = lm(x ~ year, .)) tidy(lm_fit, fit) # or as.data.frame(tidy(lm_fit, fit)) to get a data.frame # # A tibble: 6 x … Read more