-
-
Save anonymous/9e2b4b587ca507e7296e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
public class Main extends Sprite | |
{ | |
public function Main() | |
{ | |
const ELEMENTS:String = "Na Sb"; // 元素記号を半角スペース区切りで並べる | |
var str:String = "[Na(cryptand 222)]3Sb7"; | |
str = str.replace(/(?<=])(\d+)/g, "<sub>$1</sub>"); | |
for each (var element:String in ELEMENTS.split(" ")) | |
{ | |
str = str.replace(new RegExp("(?<=" + element + ")(\\d+)", "g"), "<sub>$1</sub>"); | |
} | |
trace(str); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment