Questions tagged [string]

A sequence of symbols, referred to as a string, serves various purposes such as representing textual information or handling diverse data.

Designing functions with HTML

I have been working on creating a Coffeescript function that incorporates common HTML for an object that is frequently used on my page. To make the content dynamic, I am passing a variable to the function which will be replaced each time it is called. Unfo ...

On Linux systems, Node.js in JavaScript interprets strings as objects only

I'm encountering an issue with my Discord.io bot. I am attempting to run it on a Linux server, but the Linux version of Node.js keeps treating the contents of a string as a separate object, leading to the following TypeError: TypeError: Object IT'S ALIVE ...

What is the best way to isolate specific strings that begin with a symbol from a text file using Python?

Is there a way to extract words that begin with the symbol '$' from a text file? Here is an example of the text file (ascii): @ExtendedAttr = nvp_add(@ExtendedAttr, "severity", $severity, "description", $description, "eventID", $eventID, ...

Looking for a PHP program that utilizes the Shunting Yard algorithm to interpret and evaluate a mathematical expression in string format, ultimately producing a boolean result

I am in search of a solution that can interpret a string in php and execute basic math operations, providing a boolean result to determine if the expression is true or false. For instance: Sue inputs "3*{mysalary}/9=10000" PHP breaks this down into two ...

Error interpreting the response string

After attempting to extract values from a response by parsing it into separate strings, I encountered some difficulties. The response text looks like this: response = "Data1{ key1='4722**********6', key2='2107', key3=value{ ...

Converting a decimal Unicode to a string in Javascript/Node: a beginner's guide

In my database, I have Arabic sentences that contain decimal unicodes for quotation marks and other elements. For example, here is a sample text: "كريم نجار: تداعيات “كورونا” ستغير مستقبل سوق السي ...

Encountering Keyerror while trying to parse JSON in Python

Recently, I developed a program for extracting data from an API that returns information in JSON format. However, when attempting to parse the data, I encountered a key error. Traceback (most recent call last): File "test.py", line 20, in <module> ...

How does PHP string comparison work?

I'm having trouble comparing two strings. They look similar visually, but the var_dump result is different. Can someone please help me with this issue? string(8) "СИ.pdf" string(7) "CИ.pdf" How can I correctly compare these two strings? ...

What is the method for "raw text" a variable in Python?

When opening a workbook using openpyxl, I typically use the following code: wb = load_workbook(r'seven.xlsx', data_only=True) However, there are times when the name of the spreadsheet is not known in advance, requiring me to modify the hardcoding to acco ...

Struggle with comparing strings in different cases

When utilizing the "WithText" function within a Testcafe script, it appears to be case-sensitive. How can I modify it to be case-insensitive? For example, allowing both "Myname" and "myname" for a user input. It's problematic when a script fails due to t ...

In PHP, implement a function to insert a delimiter into a string retrieved from a

Merchant Id|Merchant|Website|Transaction In Period|Voids In Period|Gross Sales Amount|Total Commision in Period 9766|Mountains Plus Outdoor Gear|www.MPGear.com|1|0|88.91|8.89 12447|Meritline.com|www.meritline.com|5|0|52.86|3.71 16213|East Coas ...

Divide the string at each second instance of an unidentified element

I have a string containing a series of coordinates that represent various polygons. Each polygon is closed, meaning it has the same starting and ending coordinates. My goal is to separate each polygon into its own string or list. '17.17165756225586 - ...

Changing a string into a list and then reversing the process

I have a rather unusual request. I am working with a string that goes through a complex processing function, resulting in a list. This list contains timestamps and text, essentially forming an LRC file (Lyric with track time). As I develop various Kodi (X ...

What is the proper way to store strings in variables within Python, and subsequently access and utilize those variables in various functions or methods within the

Recently, I encountered a straightforward issue regarding printing emojis in Python. After some research, I discovered three main methods to achieve this: Using UNICODE representation of the emoji Using CLDR names of the emoji Utilizing the emoji module ...

What is the best way to format a string containing prices using Python?

In my database, there is a field in the record table that contains prices in string format. The prices are unformatted and may vary: $12,000.50 $3.50 From $3.50 to $12,000.50 My goal is to extract the numerical value from these strings by removing all "$ ...

Methods for determining if a given character is included in a word

After conducting extensive research, I have come across various suggestions related to my topic. One such suggestion is checking if a character corresponds to a word boundary. However, I am uncertain if this is the exact solution I require for my situatio ...

I require assistance in determining the difference between two times as I am currently unable to obtain the results I

After experimenting with different methods, I have found some challenges in calculating the time difference between two values separated by a colon. The times are received through an XML feed, giving me the flexibility to manipulate and convert the strings ...

convert a string to JSON format using Node.js Express

Currently, I am viewing some string data in a browser that has been processed using python-node js express. The data looks something like this: In order to manipulate the data more effectively, I would like to convert it into JSON format that follows this ...

How to convert the Unicode characters in Python for the string 'u05d9u05d7u05e4u05d9u05dd'?

Received a Json object from a URL with values formatted like this: title:'u05d9u05d7u05e4u05d9u05dd' Attempting to convert these values into readable text, but struggling with them being interpreted as literal strings rather than unicode objects. Us ...

Tips for locating the index of a substring within a string with varying line endings using Typescript

I am faced with the task of comparing two strings together. abc\r\ndef c\nde My goal is to determine the index of string 2 within string 1. Using the indexOf() method is not an option due to different line endings, so I require an altern ...

Eliminate the generic placeholder text

Is it possible to extract only important information from a user's calendar event descriptions obtained through the Google Calendar API? For example, if we have a string like the one below: <br>Hi, please keep this text.<br> <br>Bob ...

Is it possible to remove extra characters from strings that are already in a list using Python?

Here is an example of a string within a list: items = ["hello - this", "is - a", "sample - task", "i", "want - to", "do"] Is it possible to achieve the following output? items = ["hello-this", "is-a", "sample-task", "i", "want-to", "do"] I attempted to r ...

Python Json.decoder.JSONDecodeError: Anticipating a ',' delimiter:

When attempting to load a dictionary into json, I encountered an error. strsdc = ''' {"ext":{"amznregion":["useast"],"someURL":"https://som_url.com/x/px/Iyntynt/{"c":"client&qu ...

Locating specific phrases within a vast text document using Python

The code below represents the program I have written: with open("WinUpdates.txt") as f: data=[] for elem in f: data.append(elem) with open("checked.txt", "w") as f: check=True for item in data: if "KB2982791" in item: ...

Combining individual list items into one cohesive string

I am dealing with a nested list structure like this: [ ['3', ',', '1', ',', '0', ',', '2', ',', '0'], ['2', ',', '1', ',', ...

How can PHP be used to extract values from a text string?

When using the Recurly API, the response contains the following text. My goal is to extract values from this string and assign them to PHP variables in the easiest way possible. Despite searching through various methods in the PHP manual, as a newcomer to ...

What is the best way to enclose specific characters in stringA within a tag whenever they appear in stringB?

For instance: $strA = 'What are you talking about?'; $strB = 'aeiou'; I want to enclose all vowels in strB that match any characters in strA with a <span>. Is there an efficient way to achieve this? echo tagMatchingVowels($strA); ...

How come this Python script fails to detect the numerical value within a string?

I'm facing a challenge with extracting numbers from a string that includes commas. If the comma is removed, the function works fine; however, when it's left in place, the function malfunctions. It's puzzling why the presence of a comma poses a problem for ...

Split a string in Javascript and store the resulting parts in two separate variables

After an extensive search, I haven't come across any informative posts regarding my specific inquiry. I'm currently dealing with a variable that holds a string and my objective is to split it into two separate variables. Consider this example: var str = ...

Ways to mix up a term while maintaining the original first and final characters intact (Javascript)

I've been given a task to shuffle a word that has more than 3 letters while keeping the first and last letters unchanged. The revised word should not be identical to the original, ensuring some sort of rearrangement is apparent. For example, when shuffli ...

Retrieve the substring following a specific keyword within an array of strings

I am working with a txt file that I have read as an array, where each line in the txt file is stored as an element in the array. My objective is to extract only the array elements that start with the word "Keywords:". I need to retrieve all the words follo ...

php dividing a string

Greetings, I have a question that may seem novice, but I am eager to find the answer. Back when my programming language was VB6, I used the Split method just like in PHP. However, there seems to be a key difference. When I run the following code: $page_ar ...

Substitute operation within a collection of text elements

I am trying to loop through a list of strings and replace any occurrence of a specific character, like '1', with a word. However, I'm puzzled as to why my current code is not working. for x in list_of_strings: x.replace('1', 'Ace') Just a heads up, t ...

String iteration with Stylus

Is there a way to remove the brackets and the quotation marks when putting media queries into an object and looping over them? The code works well, but the stylus is causing the output to have unwanted characters. Here's my code: $maxBreakpoints = { ...

How can a JavaScript map be created with string keys and values consisting of arrays containing pairs of longs?

Struggling with JavaScript data structures, I am trying to create a map in which the key is a string and the value is an array of two longs. For instance: var y = myMap["AnotherString"]; var firstNum = y[0][0]; var secondNum = y[0][1]; // perform opera ...

Adding quotation marks to the string form of a two-dimensional array in Python

My code takes user input from a text box and needs to convert it into a 2D list of strings. The user input comes from a Jupyter Dash text input I am working on creating a design where the user does not have to quote the elements themselves and can simply ...

Edit the contents within HTML strings without altering the HTML structure

If I have a string of HTML, it might look something like this... <h2>Header</h2><p>all the <span class="bright">content</span> here</p> I am interested in manipulating the string by reversing all the words. For example ...

Retrieving the inner content of several paragraph elements, all consolidated into a single string

I'm trying to extract the inner HTML of multiple paragraph elements from a string and I need some help. Here's an example input: let HTML = "<p class="Paragraph" >Hello, World 1!</p><p class="Paragraph" >Hell ...

How to extract part of a string delimited by certain characters within GET parameters?

I have a requirement to modify an iframe src attribute generated dynamically by a BrightCove video player. Specifically, I need to eliminate certain GET parameters such as width and height, so that the width and height of the parent element take precedence ...

Converting to alphanumeric characters using JavaScript

Is there a way to efficiently encode a random string into an alphanumeric-only string in JavaScript / NodeJS while still being able to decode it back to the original input? Any suggestion on the best approach for this would be greatly appreciated! ...

What could be causing my search function to not recognize special characters?

It seems like there might be an issue with character encoding. My JavaScript search function is unable to identify specific strings that contain certain special characters such as parentheses, asterisks, and numbers. The JavaScript code I am using is quit ...

Unpacking compressed information and organizing it into a formatted structure

Looking for the most efficient method to unpack a python string into separate fields I am working with data obtained from a TCP socket, which is packed in a string format received from the `recv` function of the socket. The format of the data is as follo ...

Encountering an Error When Trying to Read a JSON String: TypeError - string indices must be

I have been working on a program that involves reading a JSON string through a user interface and using it to perform various functions, such as breaking down mathematical equations. However, I am encountering an error message: "TypeError: string indice ...

Is there a distinction in generating variable variables using brackets versus double dollar signs in PHP?

Upon examining the PHP Manual, it appears that there isn't a significant distinction between declaring a variable variable with double brackets or double dollar signs. $apple = 'red'; $$apple = 'delicious'; echo $red; // 'delicious' $orange = 'juicy'; ${ ...

Discovering the xpath with a certain condition based on text length using Python Selenium

In my quest to extract the specific content I need from countless pages, I have devised a reliable rule that works 99% of the time: //a[@class='popular class' and not (contains(text(),'text1')) and not (contains(text(),'text2'))] The remaining 1% of case ...

Using Kotlin to work with JSON strings that contain line breaks and variables

In need of help adding linebreakers to a JSON string for improved readability. val myString = "some string" val myObjectJson = ` { "example1": "value", "example2": $myString }` This will allow me to utilize ...

JavaScript code to transform a string into a JSON array

I utilized s3 select to extract specific data for display on my frontend. I converted an array of bytes to a buffer and then to a string as shown below: let dataString = Buffer.concat(records).toString('utf8'); The resulting string looked like ...

Using the Match() function with an array of objects

I am working with an object array containing multiple variables. let Novels = []; class Novel { constructor(isbn, title, author, edition, publication, year) { this.isbn = isbn; this.title = title; this.author = author; this.publicat ...

I would greatly appreciate your assistance in creating a regular expression in JavaScript

I need assistance with creating a JavaScript regular expression that matches the format "APL-101". 1) The letters before '-' must be in capital letters, without any special characters, and can be any length. 2) After '-', the string should only contain d ...

What is the best method for deleting a portion of a string following the final instance of a particular character?

I have a single string that looks like this: "Opportunity >> Source = Email >> Status = New >> Branch = Mumbai" My goal is to truncate the string from the last occurrence of >>. Essentially, I want the resulting string to be: "Op ...

Discovering strings within strings on the Android platform

In my current project, I am dealing with a lengthy JSON text that contains movie titles. I need to extract these titles from the following pattern: ((((((( .","title":" AND ","type":" ))))))) After researching other solutions, I came across one appro ...

Converting a document into an ASCII encryption key

I am attempting to encode a user input file using a random ascii key. I have managed to generate the random key and convert the file contents into ascii, but I am struggling with how to apply the key for encryption. I have tried several approaches, but my ...

What is the correct way to utilize "%.02f" in the Python format method?

As a newcomer to Python, I recently made the switch to Python 3 and am currently getting comfortable with the format() function. My objective is to display temperatures in floating-point format using the print() function, for example: temperature = [23, ...

Increasing the value of a string in PHP

Looking to generate an array of strings that start with a random amount of letters (0 to more than 10) and end with numbers. For example: - S001, S002, ..., S015 - AB67116, AB67117, ..., AB67128 - G07, G08, G09, G10, G11 If given the starting string an ...

What is the best way to retrieve a random selection of strings from a given input?

import random def generate_random_strings(characters): return [random.choice(characters) for _ in range(4)] if __name__ == '__main__': characters = 'ygobpr' print(generate_random_strings(characters)) What is the best way to obtain a list of 4 ...

Ensure the backslashes are removed from the AWS Lambda string API response

I have an AWS Lambda function where I am sending a string as my final response let abc= `"phone_exist":"0","calls":"0","lastaction":"0"` callback(null,abc); Output: ""phone_exist":"0","calls":"0","lastaction":"0"" I'm confused about why th ...

What is the best way to identify a specific pattern within a string using regular expressions in JavaScript?

Looking for a way to extract specific values from a string? let temp = 'Hi {{username}}, Your request with request id: {{requestId}} has been processed. Please contact your nearest shop.' Desiring an array like this from the string: ['userName', 'request ...

Python code to compare strings in a list and a matrix

Looking to compare substrings within a matrix and strings within a list. l1=['phone','bag','name','after'] l2=[['phoneedjf','jshph o n ejsh','pho ne'], ['ffaf terekdl','a hf ter','fd af t e rls'], ['name s', 'ram es','her na me is'], ['ba gg in g','ba g p ...

Using Python 3.6.1 to display a string in a readable format with special characters included

Currently, I am working on a small Django 1.1 app and have encountered an issue related to Python while using commands to manage data retrieval and categorization flow. Additionally, I want to generate a summary using a third command. My development enviro ...

Using Javascript, incorporate a string variable into the response

Currently, I'm working with a node.js program and I've come across this response: 'Content-Disposition': 'attachment; filename="tts.mp3"' Instead of using "tts.mp3," I have a variable named textToConvert. How can I modify it ...

Creating a new column in a pandas DataFrame by extracting a substring from a text

I have a list of 'words' that I need to count below word_list = ['one','three'] In my pandas dataframe, there is a column containing text shown below. TEXT | -------------------------------------------| "Perhaps she ...

Simply output the integer value

Recently, I've been working on a function that I'm trying to condense into a one-liner code for a challenge on Codewars. You can find the problem here. Here's the code snippet that I currently have: export class G964 { public static digPow = (n: numbe ...

Modifying the color of an empty string is not feasible in Javascript

Is it possible to change the color of FirstName only when there is text input? Currently, it turns green when there's text, but I want it to turn red when it's empty. How can this be achieved? $(document).on("click", '.btn-info.mailContact', functio ...

Adding multiple lines of text using jQuery

I am facing an issue while trying to append a string to an HTML element. It works perfectly fine with a single line string, but breaks when I try to split it into multiple lines. <div><h4 >List to do:</h4><span id="added"></span ...

Tips for accessing a variable within a string and converting it to a Python variable

Assuming I have a small set of strings: string1 = 'text here pri=1 more text urgent=True' string2 = 'more text here pri=5 urgent=False' string3 = 'another text pri=3 urgent=False' string4 = 'more text pri=10 urgent=True' I am wondering how to extract the ...

Steps for eliminating unicode characters from a dataset using Pandas in Python

My dataset named rssfeeds has some unusual characters, how can I remove these unicodes and replace them with their original values? Here is a link to view my dataset: https://i.stack.imgur.com/CtYG0.png Any help would be greatly appreciated. ...

JavaScript code to remove everything in a string after the last occurrence of a certain

I have been working on a JavaScript function to cut strings into 140 characters, ensuring that words are not broken in the process. Now, I also want the text to make more sense by checking for certain characters (like ., ,, :, ;) and if the string is bet ...

Eliminate every instance using the global regular expression and the replace method from the String prototype

function filterWords(match, before, after) { return before && after ? ' ' : '' } var regex = /(^|s)(?:y|x)(s|$)/g var sentence1 = ('x 1 y 2 x 3 y').replace(regex, filterWords) console.log(sentence1) sentence2 = ('x y 2 x 3 y').replace(regex, filterW ...

Efficient techniques for performing multiple string replacements in Python

What is an efficient method for performing multiple string replacements quickly? I'm attempting to insert spaces to abbreviate English words like he'll -> he 'll he's -> he 's we're -> we 're we've -> we 've Additionally, I am adding spaces ...

Using JavaScript to locate and emphasize specific words within a text, whether they are scattered or adjacent

I need help finding a JavaScript code for searching words in a text using a form and a search button. I found one that works for multiple words in a row, but it doesn't work if the words are mixed up. What changes should be made to fix this issue? Any adv ...

Reduce string to designated character

There are strings in the data frame that appear as 'Temp (°C)', 'Dew Point Temp (°C)', 'Rel Hum (%)', and 'Wind Dir (10s deg)’. I want to extract only 'Temp', 'Dow Point Temp', 'Rel Hum&a ...

Combining strings with objects in Javascript: A step-by-step guide

In the code snippet provided, I am combining variables to create a path to another existing object and its attribute. The issue is that I always receive a string, but I would like to somehow convert it into an object. // SET CUSTOM CONTENT FOR COLUMN IF ...

The error message "ValueError: Precision cannot be used in integer format specifier" is thrown when

As a beginner in Python, I am currently exploring the format method. This information is from a book where I learning Python programming: The format method in Python involves substituting each argument value into the specified place. The specifications c ...

Accessing all the key-value pairs in a String array object

Looking to retrieve specific elements like host/username from the following string format. { "username":"admin", "password":"admin1234", "engine":"mysql", "host":"toolsdata.us-e ...