Jump to content

Expressões Regulares, ou não tem nada a ver com isso?


David Pintassilgo

Recommended Posts

Boas.

Tenho andado aqui a ler umas coisas mas não me entendo com isto.

O que eu estou á procura é de forma de, tendo isto:

t\t\t</td>\r', '\t\t\t\t</tr>\r', '\t\t\t\t\r', '\t\t\t</table>\r', '\t\t</td>\r', '\t</tr>\r', '</table><script type="text/javascript">var myeco = new Array(120456, 169229, 65011, 23082, 0);\r', '\tvar meco = new Array(2265034196, 768470663, 464407936, 23180864, 189307);\r', '\tvar myrac = new Array(0.92, 1.84, 3.68, 64.4, 9200);\r', '\tvar mrac = new Array(1.012, 2.024, 4.048, 70.84, 10120);\r', '\tvar numShips = 5;\r', '\tvar unitCap = 20000;\r', '\tvar unitFuel = 150;\r', '\tvar totalCap = 100000;\r', '\tecoKeyUp();\r', '\tclose = 1;</script><!--[if IE]><script language="JavaScript" type="text/javascript" src="js/iestuff.js?4"></script><![endif]-->']

Ir buscar os valores a negrito (carrega-los um em cada Variável)

não faço ideia de por onde começar a saca-los...:S

Alguém me pode dar uma mãozinha?

Eu estava com ideia que devia de usar expressões regulares, mas até não, ó que?

🙂

cool stuffs to check.

http://blog.zxcoders.com//

Link to comment
Share on other sites

Sim, é com regex. Mas como eu não sei, eu faria algo assim:

varUm = x[x.find("var myrac = new Array("):x.find(");", x.find("var myrac = new Array(")):].split("Array(")[1].split(", ")
varDois = x[x.find("var mrac = new Array("):x.find(");", x.find("var mrac = new Array(")):].split("Array(")[1].split(", ")

Não é limpo, mas funciona...

Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum!

Link to comment
Share on other sites

Não é limpo, mas funciona...

Isso não importa! 🙂 Eu normalmente também é sempre a desenrascar! 🙂

Possa,... já tou de volta disto á meia hora,.....

Pelo que eu bem percebi o x é a string, certo?

AttributeError: 'list' object has no attribute 'find'

???

(deve de ser algum pormenor da treta que me está a escapar,..é o costume...  :wallbash: )

cool stuffs to check.

http://blog.zxcoders.com//

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.