How to get first zeroes and add to the power? - visual-studio-2010

I have a variable in visual basic 2010, with the value of 0,000041 and how to make this value like this? 4.1E-5
Thank you.

the values are the same but if you want to print it or get a string out of it you can use the "E" or "e" format string:
(0.000041).ToString("E");
which should give you something like "4,100000E-005"
you can even specify how many significant digits you like with a number after:
(0.000041).ToString("e1");
gives you "4,1e-005"
you can find this and much more in the MSDN Docs

Related

Regex: Grouping with OR

I'm new here, so please don't scold me for misspellings etc.
What I need to do is to rename a bunch of files with a date in different formats at the beginning of their names, like:
05.07.2020-abc.pdf
2020.07.05-pqr.pdf
Instead of writing a different expression for each formatting, eg.
^(\d{2})\.(\d{2}).(\d{4})(.+) => $3-$2-$1$4
Example
02.11.2022-abc.pdf => 2022-11-02-abc.pdf
I'd like to do it in one fell swoop using the OR operator "|" but I have no idea how to formulate the groupings etc. Can one have nested groupings in regex?
Any ideas? Thank in advance!
#The fourth bird:
No (.+) needed. You're right, I condensed my actual expression and could have taken it out.
The different date 'formats' I mean are dd.mm.yyyy and yyyy.mm.dd respectively, and I need to convert both to yyyy-mn-dd
So,if the format is dd.mm.yyyy I have to flip the string, so to say, else I just need to replace the dots by hyphens.
The OS is Android, and for this operation I use Solid Explorer multi search & replace using regex.
I hope I made myself clear this time around ;-)

Custom Data Validation with possible Number or Word

Ok so here is what I have so far. The following works properly preventing non numbers and more than 2 occurrences of each number.
=AND(ISNUMBER(K2),COUNTIF(K$2:K$20,K2)<3)
Next I need to add in the option for the field to be 'BYE'.
So each of the cells can contain a number that cannot occur more than twice or it can contain 'BYE'
Anyone have any advice on how to achieve this? Is there a way to say it can be like this or like that?
You could use OR.
=OR(K2="BYE",AND(ISNUMBER(K2),COUNTIF(K$2:K$20,K2)<3))

XPath expression to verify a date

I woud like to know if there's a way (Using XPath) to verify if dcterms:created has been created after May 22th 1990 ? The expression should give a match if it's the case. I've tryed several things but I can't get it to work. Ex: //dcterms:created[text() > "1990-05-22"] The problem is that the comparison opertors don't seem to work because the date format isn't a recognized value.
Code that I want to search:
<dcterms:created>1990-05-25</dcterms:created>
Thanks for your help!
You are comparing strings, convert them first to a date type and than compare them:
//dcterms:created[xs:date(text()) > xs:date("1990-05-22")]

return line of strings between two strings in a ruby variable

I would like to extract a line of strings but am having difficulties using the correct RegEx. Any help would be appreciated.
String to extract: KSEA 122053Z 21008KT 10SM FEW020 SCT250 17/08 A3044 RMK AO2 SLP313 T01720083 50005
For Some reason StackOverflow wont let me cut and paste the XML data here since it includes "<>" characters. Basically I am trying to extract data between "raw_text" ... "/raw_text" from a xml that will always be formatted like the following: http://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=PHNL%20KSEA
However, the Station name, in this case "KSEA" will not always be the same. It will change based on user input into a search variable.
Thanks In advance
if I can assume that every strings that you want starts with KSEA, then the answer would be:
.*(KSEA.*?)KSEA.*
using ? would let .* match as less as possible.

Using Regex to grab multiple values from a string and drop them into an array?

Trying to grab the two $ values and the X value from this string in Ruby/watir:
16.67%: $xxx.xx down, includes the Policy Fee, and x installments of $xxx.xx
So far I've got:
16.67%:\s+\$(\d+.\d{2})
which grabs the first xxx.xx fine, what do I need to add to it to grab the last two variables and load this all into an array?
You can use the following, but regex may be unnecessary if the surrounding text is always the same:
\$(\d+.\d{2}).*?(\d+) installments.*?\$(\d+.\d{2})
http://www.rubular.com/r/sk5wO3fyZF
if you know that the text in between will always be the same you could just:
16.67%:\s+\$(\d+.\d{2}) down, includes the Policy Fee, and x installments of (\d+.\d{2})
You better use scan.
sub(/.*%/, '').scan(/\$?([\d\.]+)/)
Have you considered just splitting the string on the $ character?, then manipulating what you get with a regex or basic string commands?
/\$(\d+.\d{2}).+\$(\d+.\d{2})/ should do it. it wont matter what text is there, only that there are two "$" in the sentence.

Resources