Questions tagged [string]
A string is a finite sequence of symbols, commonly used for text, though sometimes for arbitrary data.
175,851
questions
0
votes
5
answers
34
views
How do I create a space around special characters in python?
This is what I want the code to do:
string = "1+1+1"
#insert code here
output:
>>>1 + 1 + 1
Basically I'm trying to create a " " around the special characters. (In this ...
0
votes
1
answer
18
views
Ignore Repeated content in a String in Python
I am looking for support to Ignore repeated content in a string.
a= "Item 1.01 Entry the party thereto Item 2.02 Exit Item 4.02 Please go from Item 1.01 Item 5.06 lets have some party "
I ...
-3
votes
0
answers
24
views
C++ code on checking a valid string not working [closed]
Here's the code below, when I'm taking the input from the user, I'm getting false output but when I'm declaring and initializing the string, the output is correct. (This is my first time asking a ...
-2
votes
1
answer
21
views
Python input with multiple items/requests
I'm new to coding in Python and I am stuck on the following:
I have a list of items as inputs, which is seperated by empty newlines, like so:
input = """Andrew
Bob
Chanel
Danielle
...
-1
votes
1
answer
22
views
How can I count distinct only the values in VARCHAR array?
I have a VARCHAR column with arrays in it (string as a array) in Oracle sql dialect how can I count the distinct values in it?
for example I have the following rows
ID List
1 ["351","...
-1
votes
0
answers
30
views
How to get value from pipe separated string c#
In my project, it bit old project. currently in column in the DB table, unformatted value is storing as follows.
"dif : 10546058
|schmCode : 300
|sol : 900
|ccy : LKR
|SAccountNumber : 001217
|...
0
votes
0
answers
9
views
Tidyr - Separate rows of unequal length - Remove extra strings
I am using tidyr::separate_rows to split my data into rows but I have strings of unequal lengths. See below example data:
`
Df <- data.frame(Id <- c(1, 2, 3),
suburb <- (‘orange, yellow’, ‘...
0
votes
0
answers
17
views
Extract Sentence from Text Using Match Againt MySQL and PHP
I am currently working on a Arabic book website based on PHP and MySQL
I have the following Query
SELECT page_content FROM `book` WHERE MATCH(page_content) Against('رائد' IN BOOLEAN MODE)
when users ...
0
votes
3
answers
41
views
Sort date a list of <a> tags that contain a date along with other non-date text?
This is the HTML containing a list of <a> tags containing the date within the .caption2 class. By default the list of these episodes are NOT sorted by date. How can I sort them by date with ...
0
votes
0
answers
13
views
_tkinter.TclError: expected floating-point number but got "" (when my variable gets empty)
this is my first time asking for help. I am not really an expert, so I hope this is not a newby question (sorry if it is).
Anyway, in a program in which I try to do a simple task (trying to get the ...
0
votes
0
answers
10
views
script of 2 conditions with different value comparisons
I want to create a script where theres two comparisons of 2 values then it compares it if meets the desired condition then sendds echo output. for example:
I have a value of:
A = 10
B = 15
the ...
0
votes
0
answers
10
views
Android Mpcharts xAxis write in date format
In my application, I want to show the date 1 day ahead on the x-axis instead of the number in the for loop.
Example:03/07/2022
04/07/2022
+++....
How can I do that ?
Old threads didn't help as the ...
1
vote
0
answers
54
views
How to parse a const char* from a double / long without the std::string library?
How can I parse a const char* from a double or long?
Mainly because my code is a lot faster when I use a const char*, so i decided to create a small base string class. But my code to parse a double ...
-2
votes
0
answers
23
views
what does the 19 mean in my file scan function fscanf(DataFile, "%19s", tmp)?
I have a function to print all the words in a particular file
void printAllWords(FILE * fp)
{
char tmp[20];
int i = 0;
//int lim = 0;
while (fscanf(fp, "%19s", tmp) != EOF &...
1
vote
0
answers
23
views
why doesnt the persian word add behind a number?
i have a really strange problem in java script.
look at these codes and run the app:
const number = 200000;
const persianMoney = "تومان";
//pay attention to these lines:
console.log("way 1:");
...
0
votes
3
answers
52
views
Replacing string with special characters in Pandas column
I have a large pandas dataframe where one of the columns has weird formatting. I am tring to replace the string, but I keep getting error messages saying: 'error: unterminated character set at ...
0
votes
0
answers
61
views
Java: iterating through arrays wrong? [closed]
So, I am trying to translate Morse code into English by splitting an array of strings and iterating through them. As a test case, I am entering "to be" ["- ---|-... ."]. I am ...
-1
votes
5
answers
52
views
Program to compute sum of even and odd numbers received in stream by user
In this particular code I have to find the sum of even and odd number given the by user in stream, as I can observe everything is ok in the code but still not able to run it and getting ValueError: ...
0
votes
1
answer
20
views
Find missing number from a given string in js where start and end both are provided
Here's a string with numbers from 1 - 21, it's missing one number and the string is then shuffled, you're expected to return an array of possible missing numbers.
let str = "...
0
votes
1
answer
24
views
Pandas append data in postgreSQL with { } in string
I'm try to create a executable that gets data by scrapping a website and then insert it into a local database.
I'm using SQLalchemy and psycopg2
E.g:
products = soup.find_all('div', 'product-info')
...
0
votes
1
answer
25
views
Python Flask TypeError: string indices must be integers
Using Python Flask I want to take data from excel file and pass the content of each coloumn to the html and use it to create a graph using chart.js ,but the error I am facing is string indices must ...
-2
votes
0
answers
20
views
I want to iterate over a string dictionary
I have a string that contains dictionary file, I want to convert it to a dictionary then I want to slice it.
{'09121111111':'732516'
'09122222222':'347512'
'09123333333':'928210'
'09124444444':'...
-2
votes
1
answer
22
views
Taking only letters out of string is not working in PHP [duplicate]
I have a database table which contains some application numbers. I want to take only letters out of its for example, I did the following:
$post_content="BGCG0";
$only_text =preg_replace(&...
0
votes
4
answers
43
views
How to empty the strings in an array of strings, but keep the length of array
I have an array of strings in javaScript:
array = ['xx', 'xxxxxxxx', 'xxx'];
I want to reach this:
array = ['', '', '']; //empty the strings but keep the length of array
What is the best way?
1
vote
5
answers
68
views
Is it possible to use Integers and Strings as cases in a switch case?
I've done some looking around and haven't really found much direct info on this so I'd like to just ask it directly.
Is it possible to use integers and strings in a switch case? I know the switch is ...
-2
votes
1
answer
53
views
how to remove all zeros that are 7 characters long python
I have made a string without spaces. so instead of spaces, I used 0000000. but there will be no alphabet letters. so for example, 000000020000000050000000190000000200000000 should equal "test&...
0
votes
3
answers
69
views
Write a recursive function to convert a given string into the number it represents
In this code, I want to convert the string into integer by using recursive function but it is giving output in negetive.
#include <iostream>
using namespace std;
int convert1(string s) {
...
0
votes
1
answer
33
views
What will be the output
Program
This is my program
a=30
b=444.78
c="\nkuntal Ojha"
d='\nKunal Ojha\n'
e='''Srabanti & Kuntal'''
print(a,b,c,d,e)
Output
In this output I can't understand whay for printing e ...
-2
votes
0
answers
27
views
converting an integer into a string inside a function [closed]
I was trying to make a program that convers positive numbers to negative ones and vice versa, I was planning to do this by converting the input into a string and then back to integer, but my program ...
2
votes
1
answer
66
views
Does Haskell's `readFile` read the whole file content into memory?
I want to select the n-th last line from a large text file (~10GB) in a Haskell program.
I found a way how to get the n-th last from an internal string:
myLen = 7
n = 3 -- one-based from the end
...
-2
votes
2
answers
30
views
List Problem in python to sort a list of string without using sort or sorted function
I am stuck in this list problem, I am unable to solve it.
list1= ["aaditya-2", "rahul-9", "shubhangi-4"]
I need to sort this list without using sort/sorted function.... ...
0
votes
0
answers
19
views
Python: TypeError: string indices must be integers in python
Hi I am trying to Upload a file into the blob storage using python, but while doing so i am getting the following error
TypeError: string indices must be integers
Currently My code looks like this
...
0
votes
2
answers
25
views
Removing unwanted strings, signs and space from a pandas dataframe list
I have a Department column in pandas data frame as following
Date
Department
Friday, 1 April 2022
S220- Department of Transport
Thursday, 26 August 2021
S220 Department of Transport
Friday, 1 ...
1
vote
2
answers
33
views
(r programming) How can I trim the start and end of a string in a dataframe in r, while preserving the middle?
I have a dataframe from a chess game that contains the following data:
>View(game_summary_df)
white_player black_player result white_elo black_elo
1 [White Gyc12] [...
0
votes
1
answer
41
views
Replace String only if it is not present
Let's say I have a dictionary, like this {"view": object.get("view")}. Let's say the value to be returned is "Table".
I want to add "_string" to it only if it ...
2
votes
2
answers
35
views
Function to format an HTML string of ul/li into a nested object with a specific format
Trying to convert html_string (could have more nested ul li elements) into ideal_data_output
let html_string = `<ul><li><p>one</p></li><li><p>two</p><...
-2
votes
0
answers
11
views
child nodes and parent nodes in a trie structure [closed]
What I want to do is be able to traverse each branch of each word node by node, examining if the current node (child node) has a parent node with more than one child node; so that I can implement a ...
3
votes
3
answers
49
views
Use scanf to split a string on a non-whitespace separator
I aim to scan a string containing a colon as a division and save both parts of it in a tuple.
For example:
input: "a:b"
output : -: string * string = (a,b)
My approach so far keeps getting ...
-1
votes
1
answer
27
views
PySpark string to timestamp conversion
How can I convert timestamp as string to timestamp in "yyyy-mm-ddThh:mm:ss.sssZ" format using PySpark?
Input timestamp (string), df:
| col_string |
| :-------------------- |
| 5/...
-1
votes
1
answer
40
views
The code works in some cases but gives different outputs based on the sequence of the input
Expected Output should be as such:
Download
String: Welcome to HackerRank's Java tutorials!
Double: 3.1415
Int: 42
My code gives different outputs based on what input I put in at first.
If possible ...
5
votes
3
answers
85
views
Is there a way to convert a list containing arithmetic operations which is written as a string into an actual list?
I would like to convert a String like:
s = "[2-1,2,3]"
into a list, like:
a = [1,2,3]
I tried it with json:
s = "[2-1,2,3]"
a = json.loads(s)
but it can't handle 2-1.
Is there ...
-1
votes
1
answer
24
views
Regex parse specific string in log [closed]
This is my log
2022-06-28 20:34:55.746 | INFO | product.views.product_view:list:28 - SEARCH | test serach3
2022-06-28 20:34:57.984 | INFO | product.views.product_view:list:28 - SEARCH | test ...
0
votes
1
answer
33
views
R - split column based on text pattern
I want to split a column in R that has description for Size, Color and customer for an apparel product.
The column looks like this
Size:AS - Adult Small, Colours: Black , Sold By: Elmwood
Size:YS - ...
0
votes
2
answers
29
views
What is the correct way to store all the dynamic Json response strings to a list in restassured java?
public void getresponseString() {
for (int i = 0; i < getInfoResp.jsonPath().getInt("Map.List.size()"); i++) {
ArrayList<String> country = getInfoResp.jsonPath().get(&...
-1
votes
1
answer
20
views
Add extra text while databinding
I'm trying to add some extra text to the following code but it doesn't seem to work whatever I do. The information I want to show in a label comes from a DataBinding. But I can't manipulate it like a ...
1
vote
1
answer
72
views
Find and detect a pattern in a string
I'm looking for a function that detects repeated patterns on a string, for example, if the input is:
var string = "HelloHelloHelloHelloHelloHello";
var string2 = "Hello this is a ...
-4
votes
4
answers
79
views
I want to find string in a list that start with ‘A’ in python
I tried
List1=[]
for i in name:
If i.startwith(‘A’)
List1.append(i)
Print(List1)
How can i find strings that start with ‘A’ in a list and print it but using slicing and not startwith()
-1
votes
1
answer
25
views
See if a space-seperated code in a string matches any object in a table Lua
I have a string which is a space-seperated sequence of codes such as "O R LE Pdc". The code needs to check if a code matches any object in a table (such as {"R", "BE", &...
1
vote
0
answers
29
views
Can't convert \x value to bytes format [duplicate]
I'm trying to convert \x string value to a bytes format object, but when I try to run the following code:
print(b"\x")
It throws a SyntaxError exception:
SyntaxError: (value error) invalid \...
-2
votes
0
answers
15
views
Regular expressions definitions including symbols and spaces [duplicate]
what to do
I try writing code to judge whether a word is in the target sentence or not.
current code and issue
Current code is only available for target sentence 2 and 4.
How can I match cases with a ...