如何过滤包含数字的参数? C#.NET

时间:2018-08-27 17:08:01

标签: c# .net

如果QnA结果以“ 111card.json”答复,则需要等待识别111,然后转发到单独的类对象,然后返回。

[LuisIntent("it.support")]
public async Task ITSupportIntent(IDialogContext context, LuisResult result)       
{
        var qnaResult = itKB.GetAnswer(result.Query);

        if (qnaResult.ToLower().Contains("111") || 
            qnaResult.ToLower().Contains("222") || 
            qnaResult.ToLower().Contains("333")) 
        {

目前具有上述功能,但不确定是否可以使用。它应该能够识别111card.json的一部分111。

奖励点,用于显示多种过滤方式(文本,数字,符号)等。

2 个答案:

答案 0 :(得分:2)

这正是Regex最擅长的事情:

habitosQuery.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mHabitosList.clear();
            for (DataSnapshot habitosSnapshot : dataSnapshot.getChildren()) {
                Habitos habitos = habitosSnapshot.getValue(Habitos.class);

                Checks = habitos.getChecks();
                Map<String, Boolean> sortedChecks = new TreeMap<>(Checks);
                List<Map.Entry<String, Boolean>> entryList =
                        new ArrayList<>(sortedChecks.entrySet());
                Map.Entry<String, Boolean> lastEntry =
                        entryList.get(entryList.size() - 1);

                try {
                    lastDateEntry = sdf.parse(lastEntry.getKey());

                } catch (ParseException e) {
                    e.printStackTrace();
                }
                Date today = focus.getToday();
                int diffLastToday = focus.daysBetween(lastDateEntry, today);

                for (int x = 0; x < diffLastToday; x++) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(lastDateEntry);
                    calendar.add(Calendar.DAY_OF_MONTH, +1);
                    Checks.put(sdf.format(calendar.getTimeInMillis()), false);
                }

                habitos.setChecks(Checks);
                mHabitosList.add(habitos);
                mHabitosAdapter.notifyDataSetChanged();
                habitosQuery.child(habitos.getHabitosId()).child("checks").setValue(Checks);

            }

答案 1 :(得分:2)

我建议您浏览Regular Expressions

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="cash-register.html" method="post">
    <p style="color:#A569BD; font-size:20px; text-decoration:underline; margin-left:20px;">Department Store Items</p>
    <input type="checkbox" name="products[]" value="Stainless Steel Cooking Pot">Stainless Steel Cooking Pot - $29.99<br>
    <input type="checkbox" name="products[]" value="Mini Stainless Steel Blender">Mini Stainless Steel Blender - $19.99<br>
    <input type="checkbox" name="products[]" value="Kitchen Towel Set">Kitchen Towel Set - $7.99<br>
    <input type="checkbox" name="products[]" value="Large Tan Coffee Mug">Large Tan Coffee Mug - $5.49<br>
    <input type="checkbox" name="products[]" value="5 Round Dinner Plate Set">5 Round Dinner Plate Set - $5.99<br>
    <input type="checkbox" name="products[]" value="Salt and Pepper Shaker Set">Salt and Pepper Shaker Set - $1.99<br>
    <input type="checkbox" name="products[]" value="Large Blue Broom">Large Blue Broom - $3.98<br>
    <input type="checkbox" name="products[]" value="Pink Soap Dish">Pink Soap Dish - $2.5<br>
    <input type="checkbox" name="products[]" value="Silver Bathroom Trash Can">Silver Bathroom Trash Can - $6.99<br>
    <input type="checkbox" name="products[]" value="Silk Black Bathroom Robe">Silk Black Bathroom Robe - $9.99
    <br/>
    <br/>
    <button type="button" name="yourOrder" onclick="getOrderTotal()">Submit</button>
    <br/>
    <br/>
</form>