解析表情
- <!DOCTYPE html>
- <htmlxmlns="http://www.w3.org/1999/xhtml">
- <headrunat="server">
- <metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/>
- <title></title>
- <scriptsrc="jquery.min.js"></script>
- <style>
- #emoji span {
- float: left;
- display: block;
- width:30px;
- height:30px;
- line-height:30px;
- font-size:16px;
- cursor: pointer;
- }
- </style>
- </head>
- <body>
- <formid="form1"runat="server"action="index.aspx"method="post">
- <div>
- <inputtype="hidden"name="content"id="content"/>
- <asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
- <br/>
- <divstyle=""id="emoji">
- </div>
- <inputtype="submit"value="Submit">
- <inputtype="button"id="submit"value="post submit"onclick="submmitForm()"/>
- </div>
- </form>
- <script>
- String.prototype.replaceAll =function(s1, s2){
- returnthis.replace(newRegExp(s1,"gm"), s2);
- }
- var emojiChar ='😍-😰-😅-😊';
- var emojiList = emojiChar.split('-');
- function addemoji(i){
- $('#TextBox1').val($('#TextBox1').val()+ emojiList[i]);
- }
- function submmitForm(){
- var text = $('#TextBox1').val();
- for(var i =0; i < emojiList.length; i++){
- text = text.replaceAll(emojiList[i],'['+ i +']');
- }
- $('#content').val(text);
- //alert($('#content').val());
- $('form').submit();
- }
- $(function(){
- for(var i =0; i < emojiList.length; i++){
- $('#emoji').append('<span onclick="addemoji('+ i +')">'+ emojiList[i]+'</span>');
- }
- });
- </script>
- </body>
- </html>
- List<string> list = new List<string>();
- var content = Request.Form["content"];
- if (content == null)
- {
- return;
- }
- Regex reg = new Regex(@"\[(\d{0,2})\]");
- var newitem = reg.Split(content);
- if (newitem.Length > 0)
- {
- for (int i = 0; i < newitem.Length; i++)
- {
- if (string.IsNullOrEmpty(newitem[i]))
- {
- continue;
- }
- if ((i+1)%2==0)
- {
- list.Add("<image src='" + newitem[i]+ ".gif'>");
- }
- else
- {
- list.Add(newitem[i]);
- }
- }
- }
- var c = list;
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · 小程序可以绑定其它小程序吗?
- · vue3+vite+多环境发面到二级目录配置
- · The instance of entity type ‘Customer’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked.
- · .NET8实时更新nginx ip地址归属地
- · 解决.NET Blazor子组件不刷新问题
- · .NET8如何在普通类库中引用 Microsoft.AspNetCore
- · 微信小程序防止事件穿透防止事件冒泡
- · 普通链接二维码跳转小程序
- · .NET8 Mysql SSL error
- · ASP.NET Core MVC的Razor视图渲染中文乱码的问题
- · 解决flex-direction: column 之后元素宽度自动变为100%
- · vue/react/node/vite/npm/yarn build自动更新版本号