Julia
Julia аватар
User offline. Last seen 5 недель 2 дня ago. Не в сети
Зарегистрирован(а): 07/06/2007

Parsing Optional Html Tag Attributes using none keyword

htmlYou really hate Regular Expressions and discovered the power of Parse with our simple parse tutorials. Nevertheless after a while, you feel frustrated because even after reading the excellent manual, you’re still lacking some real world examples. So here’s an example for using none with Parse.

Let’s say you want to parse this:

content: {



}

or

content: {



}

If you try this rule …

attribute1: [{attribute1="} copy valueattribute1 to {"} thru {"}]
attribute2: [{attribute2="} copy valueattribute2 to {"} thru {"}]

attributes-rule: [attribute1 attribute2 (print valueattribute1 print valueattribute2 )
| attribute2 attribute1(print valueattribute2 print valueattribute1)
]

rule: [any [to {} to {} thru {}] to end]

… the second content won’t fully parse. Instead you have to add none keywords like this:


attribute1: [{attribute1="} copy valueattribute1 to {"} thru {"}]
attribute2: [{attribute2="} copy valueattribute2 to {"} thru {"}]

attributes-rule: [[attribute1 | none] [attribute2 | none] (print valueattribute1 print valueattribute2
valueattribute1: none valueattribute2: none)
| [attribute2 | none] [attribute1 | none] (print valueattribute2 print valueattribute1
valueattribute1: none valueattribute2: none
)
| none
]

rule: [any [to {} to {} thru {}] to end]

If you test content 2 with last rule, you should get


>> parse content rule
valueattribute1
valueattribute2
none
valueattribute21
== true
>>

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->

 

В этом суть Если бы в

В этом суть Если бы в здоровый организм был введен вирус в натуральном виде, он безусловно вызвал бы заболевание и смерть

Отправить комментарий

Содержание этого поля является приватным и не предназначено к показу.

Подробнее о форматировании

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.