string Questions

3

Solved

I have a dataframe: mydf <- data.frame( col1 = c("54", "abc", "123", "54 abc", "zzz", "a", "99"), col2 = c("100"...
Focus asked 10/8 at 14:14

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...
Riproaring asked 2/10, 2012 at 21:44

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...
Samul asked 4/7, 2014 at 10:5

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...
Danielladanielle asked 7/1, 2016 at 3:47

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...
Cachet asked 28/7, 2009 at 12:4

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...
Pedantry asked 4/4, 2009 at 16:18

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...
Grained asked 28/7 at 9:38

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...
Abbreviate asked 14/2, 2011 at 5:26

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...
Developing asked 25/7 at 23:12

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...
Casteel asked 1/4, 2019 at 7:27

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 ...
Androecium asked 12/8, 2016 at 17:20

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') ...
Oddball asked 15/5, 2013 at 18:4

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...
Condensation asked 5/4, 2017 at 13:12

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...
Bousquet asked 24/12, 2011 at 21:3

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...
Helenahelene asked 1/7, 2018 at 9:9

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...
Mushy asked 18/8, 2009 at 12:2

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'
Hallux asked 6/2, 2018 at 11:46

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.