Remove and change a character on string [closed] - arrays

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have an array of strings. What I want is to remove from a string the character "," and the character "]" change it to "|".
string = 3.1321309062246026, 42.02829431948331],
and i want to get :
string = 3.1321309062246026, 42.02829431948331|
so i want to remove final "," but not the one in the middle. Also to change that ] to | . it has to change like this
3.1321309062246026,42.02829431948331|

Input
a="3.1321309062246026, 42.02829431948331],"
Code
p a.gsub(/\]/,"|").gsub(/,\z/,"")
Output
"3.1321309062246026, 42.02829431948331|"

Related

Address fields to combine with comma , with null check [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
Trying to add address fields with comma at the end of the field , but if any one of the field is missing i am getting multiple comma's

Allow special characters in e-mail Regex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
What is a proper Regex code to allow special characters like . _ - in email field
I have this Regex right now /^[a-zA-Z0-9]+#[a-zA-Z0-9]+\.[A-Za-z]+$/,
The above Regex only allow e-mails such as joedow#gmail.com
joe.dow#gmail.com does not work
How can I fix this ?
Just add those characters to the Regex:
^[a-zA-Z0-9\._-]+#[a-zA-Z0-9]+\.[A-Za-z]+$
https://regex101.com/r/xKkKIQ/1
This will make the regex consider ., _ and -. If you want any other characters, add them in the same way.

Dynamic string splitting to get the last word [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a challenge question like "What is your favorite movie?". There could be any question like this. I need last word of the question i.e. movie. without question mark.
Try this
String question = "What is your favorite movie";
String lastWord = question .substring(question .lastIndexOf(" ")+1);
When you select the element containing your challenge question, you can call .getText() (in Java; similar in other languages) to get the text inside. Then, you can use regular expressions or substring utilities in your language to strip out the last word.

User input to an array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
When using C programming language, I have no idea how to put a user input to an array.
I need to get integers from the user in from of:
printf("Enter numbers. Separate each by a comma: ");
How can I put each number into an array?
This is a very helpful link
Also look up this too for clarification on Console.Read & Console.Readline
Difference between Console.Read() and Console.ReadLine()?

split string in C and take each field separately [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to split a string i have "msg 10 2" into different strings & ints. so instead of having
msg 10 2
I can take each as a seperate parameter can print:
msg
10
2
I use the variable to define a message:
char msg[30] = "msg 10 2";
I then want to take each field as seperate values/parameters.
Thanks
If you know your string will always follow the format string int int, then you could also use sscanf.
Use strtok (which you already tagged) and atoi.

Resources