When converting between the discuz! visual editor and the Ubb editor, such as
The code is as follows |
Copy Code |
|
But the content that IE gives is
The code is as follows |
Copy Code |
|
Good double quotes just give me eat, are you hungry?
The original use is re =/alt= (["']+)" ([ss]*?) (1)/I; to match out the alt value.
Results IE gives the content can not match, the key is not double quotes, and alt value has a bit arbitrary value, Firefox does not have this problem. is very depressed, have the opportunity to let me see the person who developed IE browser kernel, I must throw a lump of excrement to him, estimate each and JavaScript and each version of the browser big dealings with the peers have the idea of it:
The Final Solution is: Add a plus a regular
The code is as follows |
Copy Code |
Re =/alt= ([ss]*?) (>|s>|ssrc|sborder|swidth|sheight|s/>| ") /I;
|
To match the non-standard content generated by IE.
The detailed code is as follows:
The following ALT value is for the standard browser that is alt= "xxxx" with double quotation mark mode;
The code is as follows |
Copy Code |
Re =/alt= (["']+) ([ss]*?) (1)/I; var matches = re.exec (attributes); if (matches!= null) { var alt = matches[2]; if (alt.length) { Return ' [img= ' + src + '] ' + ALT + ' [/img] '; } } |
The following ALT value is for non-standard browsers such as Dog Day ie, alt=xxxx, which is not enclosed in double quotes;
The code is as follows |
Copy Code |
Re =/alt= ([ss]*?) (>|s>|ssrc|sborder|swidth|sheight|s/>| ") /I; var matches = re.exec (attributes); if (matches!= null) { var alt = matches[1]; if (alt.length) { Return ' [img= ' + src + '] ' + ALT + ' [/img] '; } } |
If you have any better way please be sure to tell me Oh!! ~~
PM Update:
Thanks to Blankyao's reminder, I found the attributes in front of the last is no > symbol
So the regular revision is changed to
code is as follows |
copy code |
re =/alt= ([SS] *?) (ssrc|sborder|swidth|sheight| ") /I; |