How to split a path using ant? - ant

I have for example a path:
Path: "Abc/dbaklbdf/akldfa/das/adsa"
I need to split it on / to access the values.
How can I do that?

If you want to do this in javascript:
'Abc/dbaklbdf/akldfa/das/adsa'.split('/')
output:
["Abc", "dbaklbdf", "akldfa", "das", "adsa"]

Related

Trying to parse a custom log using grok

I have the following log:
2016-10-20T23:56:42.000+00:00 clientIp:83.149.9.216 TransactionId=1233 TransactionType=Sell
How can i ignore the words clientIp:, TransactionId= and TransactionType= to match only the values?
If I modify my log to look like this:
2016-10-20T23:56:42.000+00:00 83.149.9.216 1233 Sell
And I use this pattern:
%{TIMESTAMP_ISO8601:timestamp} %{IP:clientIp} %{NUMBER:TransactionId} %{WORD:TransactionType}
It works.
So i need a way to read only the values after "word:" or "word="
Your pattern can include literals, e.g.
TransactionId=%{NUMBER:TransactionId}

Iterating and mapping List of list

I have a list of list like this
[[emplid:01,emplname:alan],[emplid:02,emplname:john],[emplid:03,emplname:ali]]
i need the output as
[emplid:01,emplid:02,emplid03]
can anyone suggest the looping in java or gorrvy
1st off, your collection is a list of maps, not lists. Second, your output is impossible, if you want to get a map, as the later doesn't support doublets as keys
It's impossible to get the output you requested, but you can get a list of emplid's:
[
[emplid:01,emplname:'alan'],
[emplid:02,emplname:'john'],
[emplid:03,emplname:'ali']
].collect {
it.emplid
}
The output of the above is: [1, 2, 3]
For an output like [emplid1, emplid2, emplid3] you can do this:
[
[emplid:01,emplname:'alan'],
[emplid:02,emplname:'john'],
[emplid:03,emplname:'ali']
].collect {
"emplid${it.emplid}"
}

read an array on ruby on rails

I'm trying to read this array on RoR:
> importer_name = [#<RouteImporter id: 1, name: "aa", filename: "aa1", type: "RouteImporter">]
I just want to get the filename character "aa1", I tried with importer_name[2] but I didn't get nothing and I don't want 'filename: "aa1"' I just want "aa1", any idea? Thanks in advance!
you have a Ruby object stored in an array. You can access it like this(If I understand you correctly):
importer_name.first.filename

How to match url pattern in tornado such as www.abc.com/?code=abcd1234

I've googled a lot but cannot find.
For example, my app is www.abc.com, how can I match this kind of url:
www.abc.com/?code=abcd1234
My handlers:
handers = [
(r"/?", HomeHandler),
(r"/?code=([^/]+)", OtherHandler),
]
the second pattern is wrong I think, and it always use the first
Ok, I know that r"/" is path and '?code=([^/]+)' is query.

How to parse a yaml file into ruby hashs and/or arrays?

I need to load a yaml file into Hash,
What should I do?
I would use something like:
hash = YAML.load(File.read("file_path"))
A simpler version of venables' answer:
hash = YAML.load_file("file_path")
Use the YAML module:
http://ruby-doc.org/stdlib-1.9.3/libdoc/yaml/rdoc/YAML.html
node = YAML::parse( <<EOY )
one: 1
two: 2
EOY
puts node.type_id
# prints: 'map'
p node.value['one']
# prints key and value nodes:
# [ #<YAML::YamlNode:0x8220278 #type_id="str", #value="one", #kind="scalar">,
# #<YAML::YamlNode:0x821fcd8 #type_id="int", #value="1", #kind="scalar"> ]'
# Mappings can also be accessed for just the value by accessing as a Hash directly
p node['one']
# prints: #<YAML::YamlNode:0x821fcd8 #type_id="int", #value="1", #kind="scalar">
http://yaml4r.sourceforge.net/doc/page/parsing_yaml_documents.htm
You may run into a problem mentioned at this related question, namely, that the YAML file or stream specifies an object into which the YAML loader will attempt to convert the data into. The problem is that you will need a related Gem that knows about the object in question.
My solution was quite trivial and is provided as an answer to that question. Do this:
yamltext = File.read("somefile","r")
yamltext.sub!(/^--- \!.*$/,'---')
hash = YAML.load(yamltext)
In essence, you strip the object-classifier text from the yaml-text. Then you parse/load it.

Resources