Convert variable string to variable numeric

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
Hi,

I have this table:

AB
10 min50 seg
10 min1 hora

Column A is a constant that I put, and column B is a string I take from url.

I need convert strings, seg, min, hora, horas, día, dias (this is all time string url generate) to, 0.6, 1, 60, 60, 1440, 1440.

I need this for compare later two columns and if A1<B2 do something. I read in forum that I can do this with javascript


I apreciate your help.
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 775
Благодарностей
1 185
Баллы
113

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
I don´t know if you urderstand what I want.

I want conver this

var1 = 60 seg to var1convert = 1

var2 = 1 día to var2convert = 1440

var3 = 4 horas to var3convert= 240

var4 = 35 min to var4convert = 35

I want convert all times to minutes.
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
I'd do that such a way:
0. for each row
1. Parse number from column B with regexp \d+
2. Parse word from column Bwith regexp [a-z]*
3. Use switch to convert variable from step 2 into number
4. Multiply number from step 3 and step 1 by using JS.
 
  • Спасибо
Реакции: javier

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
Thanks for reply.

I make step 1 and 2, but I don't know how do step 3.

I try to do with wordprocessing but I don't find how.
 

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
I no say nothing:mad:

For step 3 I use wordprcesing/regex and you code [a-z]*

When I run template no put nothing in variable.

I use tool regurar expresion and writte 1 seg and put your code [a-z]* and fin 3 results:

0 nothing
1 seg
2 nothing

Its posible that when I use wordprocesing take number 0 o 2 result?
I don't know

bye
 

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
I no see {space} before [a-z]*
Noe I find only text

I continue :az:
 

javier

Новичок
Регистрация
25.08.2012
Сообщения
93
Благодарностей
0
Баллы
0
Finish!!!

thanks:D
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
You made it? :-)
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)