如何用一个替换双反斜杠

时间:2017-12-26 11:46:39

标签: c#

我想" PRR \ 17-18 \ 12"为PRR \ 17-18 \ 12

我尝试了以下方法,但它无效

DepositCode.Replace(" \\"," \"); DepositCode.Replace(@" \",@" \");

有人请帮忙

2 个答案:

答案 0 :(得分:1)

你想要那样的东西;

DepositCode= DepositCode.Replace(@"\\", @"\");

答案 1 :(得分:1)

尝试使用简单替换

  public static class FeedsFragment extends Fragment {
    int color;

    public FeedsFragment() {
    }

    @SuppressLint("ValidFragment")
    public FeedsFragment(int color) {
        this.color = color;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dummy_fragment, container, false);
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dummyfrag_scrollableview);
        final FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.dummyfrag_bg);
        frameLayout.setBackgroundColor(color);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setHasFixedSize(true);

        final List<Dessert> dessertList;
        dessertList = new ArrayList<>();
        //dessertList = new Dessert(context,"");


        final String curtUserId = FirebaseAuth.getInstance().getCurrentUser().getUid();

        DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
       // DatabaseReference mDatabaseGig = rootRef.child("users").child(curtUserId).child("Gig posts");
        final String id = rootRef.push().getKey();

        final DessertAdapter adapter = new DessertAdapter(getContext(), dessertList);
        recyclerView.setAdapter(adapter);

        rootRef.addValueEventListener(new com.google.firebase.database.ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {

                dessertList.clear();
                for(DataSnapshot gigSnapshot: dataSnapshot.getChildren()){
                    Dessert dessert = gigSnapshot
                            .child("users")
                            .child(curtUserId)
                            .child("Gig posts")
                            .child(id).getValue(Dessert.class);
                    dessertList.add(dessert);
                    adapter.notifyDataSetChanged();
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });

        // possible to put progress dialogue
        return view;
    }
}