string Questions
3
Solved
I have a dataframe:
mydf <- data.frame(
col1 = c("54", "abc", "123", "54 abc", "zzz", "a", "99"),
col2 = c("100"...
15
Solved
I need to write a function that will count words in a string. For the purpose of this assignment, a "word" is defined to be a sequence
of non-null, non-whitespace characters, separated fr...
2
Solved
I have a string in UTF-8 format but not so sure how to convert this string to it's corresponding character literal. For example I have the string:
My string is: 'Entre\xc3\xa9'
Example one:
This...
6
Solved
The problem:
Implement a Python function called stripComments(code) where code is a parameter that takes a string containing the Python code. The function stripComments() returns the code with all ...
Auspicious asked 9/2, 2015 at 1:35
4
Want "30 of month" but get "30"
package main
import "fmt"
func main() {
var s string
fmt.Scanln(&s)
fmt.Println(s)
return
}
$ go run test.go
31 of month
31
Scanln is similar to Scan...
8
Solved
I want to check if my string contains one or more asterisks.
I have tried this:
if [[ $date_alarm =~ .*\*.* ]]
then
...
fi
It worked when I launch the script directly, but not if this scrip...
6
Solved
Let's say I have two variables:
>>> a = "hello"
>>> b = "world"
I can concatenate them in two ways; using +:
>>> a + b
"helloworld"
Or using an f-string:
>>&...
Bula asked 4/12, 2019 at 16:29
13
Solved
$split_point = ' - ';
$string = 'this is my - string - and more';
How can I make a split using the second instance of $split_point and not the first one. Can I specify somehow a right to left sear...
6
Solved
I have the following string and would like to use str_replace or preg_replace to remove the brackets but am unsure how. I have been able to remove the opening brackets using str_replace but can't r...
Sgraffito asked 23/1, 2012 at 13:3
5
Solved
It is a simple question. I have a list of country names. However, I wanted to change few names with correct names. So, I have two more vectors; one with names to be changed, and second with correct...
50
Solved
I am trying to iterate through a string in order to remove the duplicates characters.
For example the String aabbccdef should become abcdef
and the String abcdabcd should become abcd
Here is what...
2
Solved
I'd like to find all occurrences of a substring while ignoring some characters. How can I do it in Python?
Example:
long_string = 'this is a t`es"t. Does the test work?'
small_string = "t...
6
Solved
I have a string like this:
key=value, key2=value2
and I would like to parse it into something like this:
array(
"key" => "value",
"key2" => "value2"...
Basilisk asked 7/2, 2011 at 16:51
4
Solved
This is my file.txt:
Egg and Bacon;
Egg, sausage and Bacon
Egg and Spam;
Spam Egg Sausage and Spam;
Egg, Bacon and Spam;
I wanna convert the newLine '\n' to ' $ '. I just used:
f = open(fileN...
Flagstone asked 25/3, 2015 at 9:4
5
Trying to build an uppercase to lowercase string converter in Python 3.7, this is my code:
def convertChar(char):
if char >= 'A' and char <= 'Z':
return chr(ord(char) + 32)
def toLowerCase...
20
How would I make a multiplication table that's organized into a neat table? My current code is:
n=int(input('Please enter a positive integer between 1 and 15: '))
for row in range(1,n+1):
for col...
Jacalynjacamar asked 6/12, 2013 at 3:26
14
Solved
Given two strings a and b, where a is lexicographically < b, I'd like to return a string c such that a < c < b. The use case is inserting a node in a database sorted by such keys. You can ...
7
Solved
I'm trying to find a way to print a string in hexadecimal. For example, I have this string which I then convert to its hexadecimal value.
my_string = "deadbeef"
my_hex = my_string.decode('hex')
...
5
Solved
In Python 3.x how do you print an indent of white space, the method I am looking for looked something like this
level = 3
print ('% indent symbol' % * level, 'indented text')
should print:
ind...
10
Solved
I'd like to do a function which gets a string and in case it has inline comments it removes it. I know it sounds pretty simple but i wanna make sure im doing this right, for example:
private Strin...
4
Solved
Is there any "pythonic" way to do this? I am pretty sure my method is not good:
sample = "This is a string"
n = 3 # I want to iterate over every third element
i = 1
for x in sam...
5
I have a long string in php which does not contain new lines ('\n').
My coding convention does not allow lines longer than 100 characters.
Is there a way to split my long string into multiple lin...
5
In what 8-bit ASCII-like character set for English is 0x9d meaningful?
I'm cleaning up some old data files, and occasionally finding a 0x9d in otherwise-ASCII text. (No, it's not UTF-8.)
It's not...
Biles asked 18/8, 2017 at 5:27
5
Solved
In Python, this would be final_char = mystring[-1]. How can I do the same in Rust?
I have tried
mystring[mystring.len() - 1]
but I get the error the type 'str' cannot be indexed by 'usize'
6
Solved
I've a list of IP addresses as follows
192.168.1.5
69.52.220.44
10.152.16.23
192.168.3.10
192.168.1.4
192.168.2.1
I'm looking for such a way to sort this list to match the below order
10.152.16...
Maurine asked 6/6, 2011 at 5:16
© 2022 - 2024 — McMap. All rights reserved.