Remove string from each item on array using VB [closed] - vbscript

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 last year.
This post was edited and submitted for review last year and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Basically I've an array that looks like this
array = ("Hello_123","Hello_234","Hello_345")
I would like to remove the word "Hello_" from the array so that the result would become
array = ("123","234","345")
Any idea how can I do that please?

As stated by #user692942, loop through the array and update the values using Replace() like this:
MyArray = Array("Hello_123","Hello_234","Hello_345")
For i = 0 to UBound(MyArray)
MyArray(i) = Replace(MyArray(i),"Hello_","")
Next

Related

Laravel How to filter inputs before going to the DataBase? [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 months ago.
Improve this question
Laravel How to filter inputs before going to the DataBase
what shoud i do to filter my inputs before saving to the database? i want it to be uniformed in like this format "Name" a uper case followed by lowercase.
in some cases like when the user register a full caps name i want it to be re format as the example "Name"
there's an especific PHP function to do what you need: ucfirst(). This function turns to Uppercase the first char from a string.
For example:
//If $request->name is 'JoHn' or whatever
$filtered_name = ucfirst($request->name);
//Returns 'John'
If is a case with two names, you can use the ucwords() PHP function (Turn first letter uppercase of every word from a string)
//If $request->name is 'OlivER JAMES'
$filtered_name = ucwords($request->name);
//Returns 'Oliver James'
Hope this help you.

Ruby snippet for reading lines block [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 3 years ago.
Improve this question
I am new to ruby and seeking help.
We got the csv files having the column with data shown below. Using the csv parser and fetch the column data for each in a variable.
And we want to change column data from csv file to line shown below and write to a file:
FROM
---
- - status
- New
- Delivered
TO
status from New to Delivered
Thanks #igian for help
---
- - status
- New
- Delivered
- - Milestone
- Sprint1
- Sprint
I was struggling for this. I tried to use y.second but it fails, please correct what I am doing wrong.
Looks like a YAML file, see https://ruby-doc.org/stdlib-2.6.2/libdoc/yaml/rdoc/YAML.html
Load the file then handle the array:
require 'yaml'
y = YAML.load_file( 'the_file.yaml' )
y #=> [["status", "New", "Delivered"]]
words = y.first
p "#{words[0]} from #{words[1]} to #{words[2]}"
#=> "status from New to Delivered"

How to remove numbers from a string [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 8 years ago.
Improve this question
I want the following:
"Set off to London 29min"
to become:
"Set off to London min"
I also want to remove the "min" and space as well, but I know how to do it in a very inefficient way.
This will do:
string.tr("0-9", "")
If I understand you correctly then here are some solutions.
string = "Set off to London 29min"
string.gsub!(/\d+/,"")
#=> "Set off to London min"
or if you would also like the literal word 'min' taken out as well
string = "Set off to London 29min"
string.gsub!(/(\d+|(min))/,"")
#=> "Set off to London "

how to add list of strings to a text file in ruby [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have list of strings. I am trying to append those string values to a text file.
Here is my code:
java_location = "#{second}#{first}"
The output of java_location is:
1.6.0_43/opt/oracle/agent12c/core/12.1.0.4.0/jdk/bin/java
1.6.0_43/opt/oracle/agent12c/core/12.1.0.4.0/jdk/jre/bin/java
1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java
1.6.0_35/u01/app/oracle/product/Middleware/Oracle_BI1/jdk/jre/bin/java
I want this output writing into a text file.
How can i do that?
File.write('file.txt', java_location)
You want to open the file in append mode ('a') rather than readwrite ('w+') which truncates the existing file to zero length before writing
http://alvinalexander.com/blog/post/ruby/example-how-append-text-to-file-ruby
if first && second
java_location = "#{second}#{first}"
a << java_location
File.open("/home/weblogic/javafoundmodified.txt", 'a') do |file|
a.each {
|item|
file.puts item
}
end
end

Sorting algorithms in Ruby sorting only by first digit [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
So I've been implementing a few different sorting methods (quick, merge, and insertion) and came across seemed a tad bit impractical and was wondering if someone could explain the thought process behind the behavior.
The list im trying to sort is the following:
[20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
The feedback is:
["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
If I change the 2 over to 00002 then I get a properly sorted list
["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Thanks ahead of time!
The respective two outputs that you are demostrating in the OP can be obtained as follows:
a = [20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
a.sort.map &"%05d".method( :% )
#=> ["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
a.map( &:to_s ).sort
#=> ["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Now what was the question, again?

Resources